You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
''' Update mass for all directly referenced documents in the drawing (anything that has its own view)
180
+
''' </summary>
181
+
''' <param name="oDoc"></param>
182
+
''' <returns>Boolean</returns>
183
+
Function UpdateMass(ByRef oDoc As DrawingDocument) As Boolean
184
+
185
+
' Define sheet + view objects
186
+
Dim oSheet As Inventor.Sheet = Nothing
187
+
Dim oView As Inventor.DrawingView = Nothing
188
+
189
+
' Check if there is a referenced model, update mass if there is (prevents an error on sheets with no model)
190
+
If oDoc.referencedocuments.count = 0 Then Return False
191
+
192
+
' Define flag
193
+
Dim bFound As Boolean = False
194
+
195
+
' Define referenced doc / temporary object
196
+
Dim oRefDoc As Inventor.Document
197
+
198
+
' Update the mass only if it finds the model reference
199
+
' Iterate though first level referenced documents
200
+
For Each oRefDoc In oDoc.ReferencedDocuments
201
+
202
+
' If all drawings only had assembly as the main view, wouldn't need to process parts aswell
203
+
' Check it is an iam / ipt - not presentation
204
+
If oRefDoc.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject AndAlso Inventor.DocumentTypeEnum.kPartDocumentObject Then
205
+
' Not a model document so skip to next view
206
+
Continue For
207
+
End If
208
+
209
+
'Update Reference Document - some documents don't have mass and it triggers an error if this isnt done
210
+
oRefDoc.Update2(True)
211
+
212
+
' Read the mass to prevent N/A issue / triggers generation of mass.
213
+
Dim oMassStr As String = ""
214
+
Dim oMassStr2 As String = ""
215
+
Dim bMassErr As Boolean = False ' Flag to indicate is there is an issue with the mass or it didnt work
216
+
217
+
Try
218
+
oMassStr = oRefDoc.ComponentDefinition.MassProperties.Mass.ToString() ' This throws an error on some random assemblies, when mass doesn't exist for some reason
0 commit comments