Hello
I want to read the names of the parts in the creation tree and save them in variables.
Like what:
Variable1= "Crown Ring 26"
Variable2= "EP-BC-AR
...
...
(see attachment)
Thank you for your help,
JB
capture.png
Hello
I want to read the names of the parts in the creation tree and save them in variables.
Like what:
Variable1= "Crown Ring 26"
Variable2= "EP-BC-AR
...
...
(see attachment)
Thank you for your help,
JB
Hello jb!
Despite my doubts, I managed like this:
TreePiece = InputBox("enter the name of the part to be selected as well as its number in the tree" & vbCrLf & "00-XXXXX-0-Piece-3" & vbCrLf & "'-3' being here the occurrence index")
followed by
swModel.ClearSelection2 True
bstatus = swModel.Extension.SelectByID2(stnewfilename & "@SE-XXXXX-0-Trajectory", "COMPONENT", 0, 0, 0, True, 0, Nothing, 0)
in order to select the piece :-)
See the GetComponents Method API (IAssemblyDoc)
Here is an example
Dim swDoc As SldWorks.ModelDoc2
Dim swAss As SldWorks.AssemblyDoc
Dim stOldFileName As String, stNewFileName As String
Dim bStatus As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
If swDoc Is Nothing Then Exit Sub
If swDoc.GetType <> swDocumentTypes_e.swDocASSEMBLY Then Exit Sub
Set swAss = swDoc
Dim swComponents As Variant: swComponents = swAss.GetComponents(True)
For i = 0 TB UBound(swComponents)
MsgBox swComponents(i). Name
Next
End Sub
Too good!
Thank you
Is it also possible to have the link to the room by this means?
thank you in advance
Good evening everyone,
I don't understand your request>> "Is it also possible to have the link to the room by this means?"
A+
MC
I don't understand the link of the room either?
Hello
My goal is to modify equations based on the dimensions of the parts of an assembly ( Macro equation question on the forum).
To do this, my first idea was to edit the parts in the assembly to modify the equations. (per macro)
except that:
For i = 0 To swEquationMgr.GetCount - 1 (in my program)
does not work in an edited part ==> end of the loop
So two solutions:
- 1) change swEquationMgr.GetCount to be able to read the equations in an edited part
- 2) open the parts one by one where swEquationMgr.GetCount works
The first one would probably be better for the simplicity and execution of the program. I've done some research on using GetEquationMgr Method (IModelDoc2) but haven't found anything that will help me.
For the second one, you need to have the full link to open the room:
example
Set Part = swApp.OpenDoc6("D:\LIBRARY\03-Technical Library Shoulder\EP-BC-AR. SLDPRT", 1, 0, "", longstatus, longwarnings)
Set Part = swApp.ActiveDoc
and therefore by opening the assembly to be able to read the link of the parts constituting it to open them.
Of course, this method will slow down the program.
I hope I have been a little clearer^^
Thank you
JB
All right!
PRB solved!
Thank you for your help!