Message 1 of 4
adds the weight in the active sheet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
' Verifica se il documento corrente è un file IDW
If ThisDoc.Document.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
' Ottieni il riferimento al documento del disegno
Dim drawingDoc As DrawingDocument
drawingDoc = ThisDoc.Document
' Ottieni il riferimento al foglio attivo
Dim foglioAttivo As Sheet
foglioAttivo = drawingDoc.ActiveSheet
' Verifica se un foglio è attivo
If Not foglioAttivo Is Nothing Then
' Itera attraverso tutte le viste sul foglio
For Each view As DrawingView In foglioAttivo.DrawingViews
' Ottieni il riferimento al documento di riferimento della vista
Dim referenceDoc As Document
referenceDoc = View.ReferencedDocument
' Verifica se il documento di riferimento è valido
If Not referenceDoc Is Nothing Then
' Ottieni il riferimento al componente nella vista
Dim componente As ComponentOccurrence
componente = referenceDoc.ComponentDefinition.Occurrences(View.ReferencedOccurrenceName)
' Verifica se il componente è valido
If Not componente Is Nothing Then
' Ottieni il nome del componente
Dim nomeComponente As String
nomeComponente = componente.Name
' Calcola il peso del componente
Dim pesoComponente As Double
pesoComponente = componente.MassProperties.Mass
' Crea una iProperty personalizzata per il nome del componente con il suo peso
foglioAttivo.PropertySets.Item("Inventor User Defined Properties").Add(iPropName:=nomeComponente, iPropType:=Inventor.ValueTypeEnum.kDoubleType, iPropValue:=pesoComponente)
End If
End If
Next
Else
' Nessun foglio attivo nel documento
MsgBox("Nessun foglio attivo nel documento.")
End If
Else
' Il documento corrente non è un file IDW
MsgBox("Il documento corrente non è un file IDW.")
End If
Hi everyone
I would need to add the weight of the components present in the active sheet even if they are not an assembly.
I found an ilogic rule but it doesn't work, can anyone help me understand the error.
Thanks to all