Update SubAssembly mass From the main Assembly

Update SubAssembly mass From the main Assembly

rcoi
Contributor Contributor
298 Views
3 Replies
Message 1 of 4

Update SubAssembly mass From the main Assembly

rcoi
Contributor
Contributor

Hello everyone,

 

This is the context, I have an assembly with many subassemblies that do not have the mass properties updated (like the picture below). What I want to do is code that allows me to update the mass from the first level assembly. I looked in forums related to the subject but I have not found what I was looking for.

If anyone can help me thank you very much.

UPDATE MASS.JPG

0 Likes
299 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @rcoi.  Have you tried looping through all of the main assemblies referenced documents and using the Rebuild method on them?  Here is an example:

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
For Each oRefDoc As Document In oADoc.AllReferencedDocuments
	If Not oRefDoc.IsModifiable Then Continue For
	Dim oMassProps As MassProperties = oRefDoc.ComponentDefinition.MassProperties
	oMassProps.MassOverridden = True
	oMassProps.MassOverridden = False
	oRefDoc.Rebuild2(True)
Next
oADoc.Rebuild2(True)

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor

There is also a command that can be executed which will cause the mass properties to be updated, similar to clicking on that button in the Physical tab of the iProperties dialog.  But I think it will only work on the 'active' document.  And as long as you are working within an assembly, that top level assembly will always technically be the 'active' document, so I'm not sure how it could be effectively used in a scenario like this.  What is needed is a method added to the MassProperties object that will cause the same effect.

ThisApplication.CommandManager.ControlDefinitions.Item("AppUpdateMassPropertiesCmd").Execute

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 4

rcoi
Contributor
Contributor

I run this Rule but it doesn't make changes on the Properties. Also I test some changes and didn't work to. Its doesn't throw any error, just dont change the propertie. I think that the logic you use is the correct way, but I dont know how to make it work.

0 Likes