Adahm
Guest
Does anyone know if you can select a part of a multi-level set in vba?
with ilogic there is the .select command with the following syntax:
odocdef.selectset.select (oocc)
where odocdef is the axieme and oocc is the component of the axieme to be selected.
But there are two problems.
the code I used is as follows:
in my case only the parts that have certain characteristics, but that is a detail.
I attach a small set of examples for those who didn't have one to do two tests.
in the file together001 there is already the code shown above.
file version: inventor 2023.
Thank you.
with ilogic there is the .select command with the following syntax:
odocdef.selectset.select (oocc)
where odocdef is the axieme and oocc is the component of the axieme to be selected.
But there are two problems.
- I can't find the same command in vba
- the command selects only the components of the first level.
the code I used is as follows:
Code:
syntaxeditor code snippetsub main()
dim assydoc as assemblydocument
dim compdef as componentdefinition
dim compoccurrence as componentoccurrence
assydoc = thisapplication.activedocument
'start exploration from active axieme
explorecomponents (assydoc.componentdefinition)
end
'recurring function to explore the hierarchy of components
sub explorecomponents(compdef as componentdefinition)
dim i as integer
for i = 1 to compdef.occurrences.count
compoccurrence = compdef.occurrences.item(s)
if compoccurrence.definitiondocumenttype = 12291 then ' iscomponentdefinition then
' if it is a defined component (can contain other components)
explorecomponents (compoccurrence.definition)
♪
' messagebox.show("part selected: " & compoccurrence.name)
call partselection (compdef, compoccurrence)
end if
next i
end
sub partselection (odef, oocc)
dim odocdef as document
odocdef = odef.document
dim odococc as document
odococc = oocc.definition.document
dim opropset as propertyset
opropset = odococc.propertysets.item("inventor user defined properties")
dim oprop as [Property]
on error resume next
oprop = opropset.item("foratura")
if oprop.value = "sì" then
odocdef.selectset.select (oocc)
end if
end sub
I attach a small set of examples for those who didn't have one to do two tests.
in the file together001 there is already the code shown above.
file version: inventor 2023.
Thank you.