- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Check if mass is filled on drawing.
Hello everyone,
Don't ask me how, but I have colleagues who create a PDF where the mass is not updated (N/A). Now I have made a button to create a PDF. In this code I want to add that a check is first done whether the mass is filled and not N/A. Unfortunately I can't figure out how to do this. The mass on the drawing is filled by the property "Physical Properties - Model -> MASS".
Hopefully somebody can help me. Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
Enable the "update physical properties on save".
Now, you will be sure that the parts and assemblies update mass after a modification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
That is on, but then you have to save the file. So I have colleagues who modify the file and then create the pdf. That's why you want to build in the check.
People are difficult. Doesn't matter how many times you tell them not to do that. ![]()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dim ModelDef As Inventor.ComponentDefinition = Nothing
Dim oDoc As DrawingDocument = oApp.ActiveDocument
Dim ModelDoc As Document = Nothing
Try
ModelDoc = oDoc.ReferencedDocuments.Item(1)
Catch
End Try
If ModelDoc IsNot Nothing Then
If ModelDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
ModelDef = CType(ModelDoc, Inventor.AssemblyDocument).ComponentDefinition
ElseIf ModelDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
ModelDef = CType(ModelDoc, Inventor.PartDocument).ComponentDefinition
End If
End If
If ModelDoc IsNot Nothing Then
ModelDoc.Update()
Dim strMass As Double = ModelDef.MassProperties.Mass
oDoc.Update()
End If
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thank you for your comment. Unfortunately, the code is getting a lot of errors and I'm not really sure how to solve them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This code should work fine.
Only thing you have to change is:
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Perhaps you can show the rule you are running?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
That was indeed the problem. Now it works.
This works perfectly for mass updating before creating a PDF. Only I am actually more looking for the possibility to give feedback if the drawing still says N/A. Do you happen to know if this is a possibility? I try to teach them instead of promoting a wrong way of working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm not sure how to get a warning message if mass = N/A
As I remember it: as soon as you call the value, it updates.
Whatever going on in the background of Inventor to make it: N/A
I don't think you can access that as a 3th party. But perhaps I'm wrong.
Perhaps you can call the text in the textbox, but then I need to know what textbox, and if it is text in the title block or in a sketched symbol.
To be honest: why bother
Weight N/A was my first frustration to get into automating Inventor 12 years ago.
If you batch 50 drawings, no matter how punctual you work, there will still be a few with weight N/A.
That frustrated me so I automated the whole process with various checks on balloons, weight, partslist etc.
Ofcourse some people manage to do it wrong every time, but why stress about it if you can easily make it foolproof and automated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report