-
Re: Silhouette of a solid body projected on a face
Brandon Massoni Jan 5, 2015 11:19 PM (in response to Brandon Massoni)Turns out SolidWorks help actually has a really good example. With a little editing, the attached code now draws an outline of the body(s) on either the X,Y, or Z plane. The sketch plane is dependent on the normal of the face you've selected. But I doubt this will capture curved surfaces if drawn at an off-axis plane. The next step is to figure out how to sketch the outline on a user created plane.
-
GetBodyOutline.swp.zip 14.3 KB
-
Re: Silhouette of a solid body projected on a face
Keith Parker Jan 6, 2015 8:17 AM (in response to Brandon Massoni)Thanks for putting the work in Brandon ... I'll give this macro a go as soon as I can. One thing that this may help with as well is the ability to select all edges of a face to use as a sketch; normal operation of the Convert Entities function only converts the 'outside' edges (I know you can Cntrl-select other regions), not all edges.
Cheers, Keith
-
Re: Silhouette of a solid body projected on a face
Brandon Massoni Jan 6, 2015 7:20 PM (in response to Keith Parker)Ok, I modified the code from "API help" to now sketch the outline on either a face or plane that is selected. I think it works for silhouette edges as well, but I'm curious if anyone has a part it won't work on.
-
GetBodyOutline2.swp.zip 21.4 KB
-
Re: Silhouette of a solid body projected on a face
Brandon Massoni Jan 8, 2015 2:10 PM (in response to Brandon Massoni)The GetBodyOutline2.swp file may work for simpler shapes, but it created an absolutely terrible sketch when I tried a shape with cavities in the direction normal to the plane. The "IModeler::GetBodyOutline2" method selects curves, extracts the endpoints, and draws a line between the points (therefore converting circular edges into straight lines). I am going back to my other method (based on converting all edges onto a sketch), which is a bit further along now (attached). It's issues are currently:
1. How to add relevant silhouette edges to selection
2. How to extrude after all regions are selected OR BETTER how to remove all the inner lines from the sketch
Thanks in advance,
Brandon
-
Silhouette.swp.zip 18.6 KB
-
Re: Silhouette of a solid body projected on a face
Simon Turner Jul 7, 2015 3:41 AM (in response to Brandon Massoni)I had a need for something similar, so I finished off this macro.
It really only needed the sketch regions selected with zero as a mark.
I have left the extrusion as using the entire collection of sketch regions rather than getting the resulting face, deleting the extrusion and re-extruding the outer boundary. It seems to work OK as it is.
I changed it to use a reference plane rather than a face, and have made it extrude to the extents of the model (+1mm in the first direction, because that is what I needed).
Enjoy.
-
Silhouette.zip 21.2 KB
-
-
-
-
-
-
Re: Silhouette of a solid body projected on a face
Neil Jackson Aug 5, 2015 2:09 AM (in response to Brandon Massoni)Very clever solution! This certainly works for any solid for which each face is planar, and even for a great many solids that have some non-planar faces. However, this method fails to extract the edges of the shadow cast by certain rounded faces. For instance, this method would have trouble finding the outline of the shadow of a sphere.
One way to work-around this limitation (admittedly a bit of a hack) would be to convert the surface into a triangular mesh (as if you had exported the solid to an stl file and then imported the stl file as a solid body (the solidworks API may offer a more straightforward to do such a conversion)), and then apply the technique to the triangular mesh.
I reckon that the curves generated by the SldWorks.Modeler.GetBodyOutline2() function are very nearly what your technique would produce if you were to triangularize the solid before applying your technique.