API VBA: MOVE/COPY BODY

Discussion in 'SolidWorks' started by Corey Scheich, Oct 16, 2003.

  1. 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
     
    Corey Scheich, Oct 16, 2003
    #1
  2. 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
     
    Corey Scheich, Oct 17, 2003
    #2
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.