API: PartDoc::GetEntityByName

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

Reply to
Brian Vogel
Loading thread data ...

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.

Reply to
Corey Scheich

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.

"Corey Scheich" wrote in news: snipped-for-privacy@uni-berlin.de:

Reply to
Brian Vogel

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

Reply to
Juan C Perez

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.