batleo
Guest
Hello everyone
I would have the need to add the weight of the components present in the ative foliage even if they are not a set.
I found an ilogic rule but it doesn't work, someone can help me understand the error
I would have the need to add the weight of the components present in the ative foliage even if they are not a set.
I found an ilogic rule but it doesn't work, someone can help me understand the error
Code:
' verify if the current document is an idw file
if thisdoc.documenttype = documenttypeenum.kdrawingdocumentobject then
' get the reference to the drawing document
dim drawingdoc as drawingdocument
drawingdoc = thisdoc.document
' get reference to active sheet
dim sheet as sheet
active sheet = drawingdoc.activesheet
' check if a sheet is active
if not folioactive is nothing then
Itera through all the views on the sheet
for each view as drawingview in foliage.drawingviews
' get reference to the reference document of the view
dim referencedoc as document
referencedoc = view.referenceddocument
' verify if the reference document is valid
if not referencedoc is nothing then
' get the reference to the component in the view
dim component as componentoccurrence
component = referencedoc.componentdefinition.occurrences(view.referencedoccurrencename)
' check if the component is valid
if not component is nothing then
' get the component name
dim namecomponent as string
component name = component.name
' calculates weight of the component
dim weightcomponent as double
weightcomponent = component.massproperties.mass
' creates a custom iproperty for component name with its weight
folioactive.propertysets.item("inventor user defined properties").add(ipropname:=component name, iproptype:=inventor.valuetypeenum.kdoubletype, ipropvalue:=pesocomponent)
end if
end if
next
♪
'No active sheet in the document
msgbox("no active sheet in the document. "
end if
♪
'current document is not an idw file
msgbox("the current document is not an idw file.")
end if