API: PartDoc::GetEntityByName

Discussion in 'SolidWorks' started by Brian Vogel, May 17, 2004.

  1. Brian Vogel

    Brian Vogel Guest

    I was planning on naming some faces in order to help with mating. I need
    to insert both parts and assemblies, and mate faces on each. Here is roughy
    what I am trying to do, this time inserting a part into :

    Dim Asm As SldWorks.AssemblyDoc
    Dim Comp As SldWorks.Component2
    Dim PardDoc As SldWorks.PartDoc
    Dim ComponentPart As SldWorks.ModelDoc2
    Dim Face As SldWorks.face2

    Set Asm = swApp.ActiveDoc
    Set Comp = Asm.AddComponent4("C:\MyPart.SLDPRT", "",0,0,0)
    Set ComponentPart = Comp.GetModelDoc
    set PartDoc = ComponentPart

    Set Face = PartDoc.GetEntityByName("CoincidentFace", _
    SwConst.swSelectType_e.swSelFACES)

    Face.Select4(false,true)


    The select call fails (returns false), but GetEntityByName does actually
    return a face. Does anyone know why Select4 from the entity is not
    working?

    Thanks,

    Brian
     
    Brian Vogel, May 17, 2004
    #1
  2. You are having trouble because Select4 is not a method used with the face2 object. so what you will have to do is.
    Dim FaceAsEnt as SldWorks.Entity
    Set FaceAsEnt = Face
    FaceAsEnt.Select4(false,true)

    It seems you are early binding. When you hit the period key after your object name VB creates a list of all the available Methods, functions and properties, if something isn't in the list it isn't available through that object.
     
    Corey Scheich, May 17, 2004
    #2
  3. Brian Vogel

    Brian Vogel Guest

    Figured itout!

    In the OLE flavor of sw, the face2 inteface inherits from the entity
    interface, therefore you can call Select4. The reason the face wasn't
    getting selected is because AddComponent returns a reference to the
    component open in another document. So, it is a matter of selecting the
    component in the assembly then making the calls.
     
    Brian Vogel, May 18, 2004
    #3
  4. Brian Vogel

    Juan C Perez Guest

    Face.Select4(false,true)
    Your mistake is that you're loading a function that return a value, if
    that's your case you should write the line like this...

    Face.Select False, True
     
    Juan C Perez, Jun 4, 2004
    #4
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.