API question: "save as" STL (with color) file format?

Discussion in 'SolidWorks' started by yung, Mar 27, 2006.

  1. yung

    yung Guest

    Hi!

    I am using Solidworks API in VC++ 6.0
    I could use "saveAs4" to save as STL files.
    But now I wish to save to STL files with color information (R,G,B)
    Is it possible for me to do this?

    Thank you!
     
    yung, Mar 27, 2006
    #1
  2. yung

    Mr. Who Guest

    Well I'm sure you've already been through the API help. Nothing there
    that I could see to help you out. In fact, from looking at the
    SolidWorks UI I don't think this can be done (ie - file -> save). If
    it isn't possible through UI it most certainly wouldn't be available
    through the api. Perhaps there is a third party program for opening
    and saving SW files as STL you could utilize?
     
    Mr. Who, Mar 27, 2006
    #2
  3. yung

    That70sTick Guest

    Why color an STL?
     
    That70sTick, Mar 27, 2006
    #3
  4. yung

    yung Guest

    Thank you, Mr Who. Indeed, no special type of STL could be saved in
    SolidWorks UI.
    Actually I searched on the web and found something about coloured STL
    in links such as this:
    http://rpdrc.ic.polyu.edu.hk/old_files/stl_colour_binary_format.htm

    What I wish to do is to obtain the colour information from a part or
    assembly file.
    STL format stores vertices and normals, while in the API color
    information can be obtained only by features or faces (using
    MaterialProperties). I have the problem of matching the color obtained
    from API methods with STL structure.

    Thanks a lot.
     
    yung, Mar 28, 2006
    #4
  5. yung

    Mr. Who Guest

    I see. It might be possible, but I am having trouble getting my head
    around it.
    the form of triangles. Each triangle can have its own color. So the
    million dollar question is; How do you map the color on a face to the
    triangles that get mapped out to an STL file?

    The answer is to hire a $10 an hour intern to spend the whole summer
    color mapping =). Seriously though, you would have to find some means
    of correlating the normal and vertex information with SolidWorks normal
    and vertex information. But one thing you should investigate and may
    not work is whether normals stay the same when exported to STL. There
    will be two types of surfaces exported, planar and nonplanar. I would
    assume the SolidWorks STL export has to break up nonplanar surfaces
    into many triangles. These will be difficult to analzye and we can
    return to later. Let's start by thinking about planar surfaces.

    Start by making sure that exported planar surfaces properly report
    their normal direction. Export a cube and match the triangles with the
    SW model. If the normal information is correct then you are good to
    continue.

    Now you have to consider planar surfaces that have curved edges. I
    assume these will get broken up into multiple triangles for STL too.
    And I'm pretty much out of ideas here. Without being able to correlate
    vertice information to SolidWorks edge/vertice information there is now
    way to determine whether a specific triangle originally made up a face.

    My next suggestion would be to put in an enhancement request to
    SolidWorks because all of this would be a LOT easier if the translation
    tool actually wrote out the color information for you.
     
    Mr. Who, Mar 28, 2006
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.