Description
Temporary bodies are used to create bodies without standard features or to increase the performance of tasks involving bodies.
Notes
Correction: at 10:24 the callout says “IPartDoc::CreateBodyFromFeature3” when in fact I am using IPartDoc::CreateFeatureFromBody3.
Concerning method versions: I have noticed, and SolidWorks API tech support has confirmed, that many of the newest versions of the IModeler methods contain bugs. If you find that an IModeler method is returning Nothing for no good reason, try using the older version. Two known examples of this are IModeler::CreateBodyFromBox3 and IModeler::CreateCylindricalSurface2, which is why you should use the older versions. Also, as of SolidWorks 2011 SP 5.0, IModeler::CreateExtrusionSurface may fail as well.
Concerning surface bodies: Creating surface bodies with IModeler is significantly more complicated than creating solid bodies. After you create the surface body you will need to trim it with curves created from methods like IModeler::CreateLine and IModeler::CreateArc. These curves, in turn, must be used with ICurve::CreateTrimmedCurve2 before they can be used with ISurface::CreateTrimmedSheet. Finally, an extruded body can be created from the trimmed surface body using IModeler::CreateExtrudedBody. See the API Help example “Create Temporary Extruded Body (VBA)” for a demonstration of this.
IBody2 and IModeler contain some duplicate functionality. For example, IModeler::CreateBodyFromFaces2 and IBody2::CreateBodyFromFaces are fairly similar. When you use one of the IBody2 calls, however, you need to already have a permanent body. You can create a “empty” body using IPartDoc::CreateNewBody and then run your IBody2 call on that body.
Lesson Files
Lesson 7.3 – create spike – start
Lesson 7.3 – create spike
Code snippets