API VBA: MOVE/COPY BODY

Oct 16, 2003 1 Replies

I am writing a macro to add a body from a file to a part and move it to a location. The problem I am having is when I use FeatureManager::InsertMoveCopyBody2 it tells me that the body is no longer in the model when it clearly is and is selected. Am I missing something. Here is an example of what I am doing.


Dim swApp As SldWorks.SldWorks Dim MyTool As SldWorks.body2 Dim FeatMan As FeatureManager Dim CatchAll As Object Dim Part As SldWorks.PartDoc Dim AsModelDoc As SldWorks.ModelDoc2 Dim ThisPoint As SldWorks.SketchPoint



Set swApp = CreateObject("SldWorks.Application") Set Part = swApp.ActiveDoc Set AsModelDoc = Part



Set thisPoint = 'somepoint Set FeatMan = AsModelDoc.FeatureManager



Set CatchAll = Part.InsertPart("G:\users\cds\TEMP\MyTool.SLDPRT", False, False, False) CatchAll.Name = "Tool1"



Set MyTool = CatchAll.GetSpecificFeature



CatchAll.Select False



FeatMan.InsertMoveCopyBody2 ThisPoint.x, ThisPoint.y, ThisPoint.z, 0, 0, 0,



0, 0, 0, 0, True, 0


I got it you have to go a round about way of selecting the body.

Dim FeatFaces as variant Dim MyFace1 as SldWorks.face2 Dim Mill as SldWorks.body2 Set Feat = Part.InsertPart("G:\users\cds\TEMP\MyTool.SLDPRT", False, False, False)

FeatFaces = Feat.GetFaces

Set MyFace1 = FeatFaces(0) Set Mill = MyFace1.GetBody

Mill.Select True, 1

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required