Check if mass is filled on drawing.

Check if mass is filled on drawing.

FeelGoodGirl
Advocate Advocate
554 Views
8 Replies
Message 1 of 9

Check if mass is filled on drawing.

FeelGoodGirl
Advocate
Advocate

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!

0 Likes
555 Views
8 Replies
Replies (8)
Message 2 of 9

CCarreiras
Mentor
Mentor

Hi!

Enable the "update physical properties on save".
Now, you will be sure that the parts and assemblies update mass after a modification.

 

ccarreiras_0-1678096997848.png

 

CCarreiras

EESignature

Message 3 of 9

FeelGoodGirl
Advocate
Advocate

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. 😉

0 Likes
Message 4 of 9

Cadkunde.nl
Collaborator
Collaborator

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

Message 5 of 9

FeelGoodGirl
Advocate
Advocate

Thank you for your comment. Unfortunately, the code is getting a lot of errors and I'm not really sure how to solve them.

 

ymvdbosch_1-1678105241482.png

 

0 Likes
Message 6 of 9

Cadkunde.nl
Collaborator
Collaborator

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?

Message 7 of 9

FeelGoodGirl
Advocate
Advocate

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

0 Likes
Message 8 of 9

Cadkunde.nl
Collaborator
Collaborator

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.

0 Likes
Message 9 of 9

FeelGoodGirl
Advocate
Advocate

That's a good point. I'm going to add this. Thank you for your help.

0 Likes