Search code examples
solidworkseyeshot

Make the coordination system of all entities of the STEP file up-z


go on STEP File's entities UpdateOrientedBoundingBox

In solidworks,They build an assembly from many parts. Each part has own coordination system. when they built up all of parts to an assembly,and each part may be rotated. then,not all entites are Up-z, maybe some entities are Up-y ,some entities are Up-x. when i export to a step(AP214),these attributes are reserved. I load the step to my viewport,i want make all entities are Up-z. then,i call translate(0,0,1000) the entites will move Up , not Left in my view.


Solution

  • There is no such thing as UpZ or UpX in Solidworks. Everything is UpY.

    When you make an assembly all parts are either positioned manually or using mates (99% of the time). This process will nearly all the time rotate and translate the part.

    When you export to Step or Iges (2 main export format that Eyeshot can use) All geometry that are generated in those files do not contain the original matrix. If you look at the vertex of a part you will see the vertex of the Mesh are positioned relative to the world and not to an internal matrix.

    That being said if you loop through all entities in the viewport and translate each of them in Z they will ALL move in the same direction.

    In order to keep the final matrix the principle is quite easy as i have done it already but you need to know your way around the Solidworks API. You need to create a Solidworks Addin and add a button or menu to Solidworks. Then once you code something to export each parts individually into step which will keep their original rotation before being modified into the assembly. If you have 10 parts you should end up with 10 Step files unless the same part is used many times in the assembly then you will have less.

    Finally you need to use the assembly to get the matrix of each part in the assembly and make some sort of file with an association of PartName to Matrix so you should have every single parts.

    When you get to Eyeshot all you have to do is load the proper step and apply the matrix you saved in the file. Then if you want to move everything relative to their own Z axis you simple create a Z vector with the wanted displacement i.e. : (0, 0, 1000) and transform that vector by one of the part matrix and then translate that same part by the transformed vector. And finally you repeat the same process for each parts.

    Adding this part with an easier to read step by step for the process of getting the real matrix :

    1. Open Solidworks
    2. Open the assembly you are interested in (whatever.sldasm)
    3. Click the button or menu you created with the API
    4. Take a part of the assembly and open it (i.e. part1.sldprt)
    5. Export to Step as part1.step
    6. close the part document and return to the assembly document still opened
    7. get the matrix of the part1.sldprt and save it to a text file so you can read it later
    8. repeat step 4 to 7 until all parts are done
    9. in eyeshot open each part Step files and transform the block by the matrix in the text file.
    10. all done