To be able to add a constraint, in a macro I need to select a named face of a part in an assembly, I have something like below, but it doesn't work
' boolstat = swModelDocExt.SelectByID2("Fond@col_60-1@ass", "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)
Can anyone help me?
thank you in advance
AF
pl
June 7, 2016, 11:01am
2
Hi, do you know the name of the play?
Yes
It is: col_60-1
ASS is the name of the assembly
the name of the face is: Fond
pl
June 8, 2016, 7:44am
5
I just saw that your line starts with an apostrophe: it should be removed because it's the sign for comments and it doesn't know what is written after it!
' boolstat = swModelDocExt.SelectByID2("Fond@col_60-1@ass", "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)
=>
boolstat = swModelDocExt.SelectByID2("Fond@col_60-1@ass", "PLANE", 0, 0, 0, True, 1, Nothing, swSelectOptionDefault)
Correct
but it was a try that doesn't work so I had put it in the comments
CDLT
pl
June 8, 2016, 9:01am
7
Is the guy good?
You indicate a plane "PLANE" while you talk about a face "FACE"
http://help.solidworks.com/2015/English/api/swconst/SOLIDWORKS.Interop.swconst~SOLIDWORKS.Interop.swconst.swSelectType_e.html
Interesting information here too:
http://help.solidworks.com/2015/English/api/sldworksapi/Get_Component_Face_By_Name_Example_VB.htm
pl
June 8, 2016, 9:06am
8
In fact, here they say that this statement doesn't work and that you have to use GetEntityByName and then Select4
https://forum.solidworks.com/thread/62936
An example of this GetEntityByName statement :
http://help.solidworks.com/2014/English/api/sldworksapi/Get_Component_Name_From_Selected_Entity_Example_VB.htm
Ok I'll look into all this
but my goal is not to have human intervention
CDLT
1 Like
pl
June 8, 2016, 1:19pm
10
With GetEntityByName , there is no question of human intervention! And I think it will work better than "SelectByID2".
Indeed the solution is in this example:
http://help.solidworks.com/2015/English/api/sldworksapi /Get_Component_Face_By_Name_Example_VB.htm
I have attached part of my program
CDLT
select_component_face_by_name_example_vba.txt
pl
June 9, 2016, 11:56am
12
And the program works now?
If not, which line is in error and what is the error?