part weight settings

part weight settings

Anonymous
Not applicable
611 Views
5 Replies
Message 1 of 6

part weight settings

Anonymous
Not applicable

Hi, all!  I tried searching for this issue, no luck... for a lot of the parts in our Library we have a simple model which fills our needs, and we "overwrite" the weight of the model file so it is correct.  We have a macro which we use to fill in iProperties, and I would like to include this option, but I can't find the Design Tracking Property code to use.  Is it possible to overwrite the weight of a model using VBA?  We are using Inventor R2011, SP2 (yes, we're a bit behind the times... hoping to be able to upgrade sooooonnnnn Smiley Happy)

0 Likes
Accepted solutions (1)
612 Views
5 Replies
Replies (5)
Message 2 of 6

rossano_praderi
Collaborator
Collaborator

Hi Joe,

I'm not using Inventor 2011 and I can't test this code on that release.

 

The follow VBA code give the complete list of propertysets.

 

 

Sub test()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    For i = 1 To oDoc.PropertySets.Count
        Debug.Print oDoc.PropertySets.Item(i).Name
        For e = 1 To oDoc.PropertySets.Item(i).Count
            Debug.Print "-> " & oDoc.PropertySets.Item(i).Item(e).Name
        Next
    Next
End Sub

' changing the Mass can be like this
' oDoc.PropertySets.Item("Design Tracking Properties").Item("Mass") = YourMass

 

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 3 of 6

Anonymous
Not applicable

Thanx a bunch, the code runs in 2011, so the functionality is there.  It doesn't update the model file, is there a need to "apply" or "update" the change?  Thanx again

 

0 Likes
Message 4 of 6

dano0310
Advocate
Advocate

For a list that can be printed out check page 13 of "Exploring iProperties and Parameters".  It was from 2008 but still relevant. Click here

 

The code below:

 

MsgBox ("The mass of this item is " & ThisApplication.ActiveDocument.PropertySets(3).ItemByPropId(58).Value)

 

Returns the mass from iProps.  It can also be written

 

Property set 1 is the Inventor Summary information

Property set 2 is the Inventor Document Summary information

Property set 3 is the Design tracking properties

 

 

Message 5 of 6

rossano_praderi
Collaborator
Collaborator
Accepted solution
Yes, you should use "oDoc.update".


--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
Message 6 of 6

Anonymous
Not applicable

Thanx, everyone for their help!  Accessing the Design Tracking Property gave me the mass of the model, but changing it didn't change the mass (???).  I used this code and it did the job.

 

Dim oAssyDoc As AssemblyDocument
Dim oPartDoc As PartDocument
Dim oMass As Double

    'Set oAssyDoc = ThisApplication.ActiveDocument
    Set oPartDoc = ThisApplication.ActiveDocument
    Dim oMassProps As MassProperties
    'Set oMassProps = oAssyDoc.ComponentDefinition.MassProperties
    Set oMassProps = oPartDoc.ComponentDefinition.MassProperties

oMass = (whatever the new value is, I'm getting it from a User Form)


oMassProps.Mass = oMass
Debug.Print "Mass: " & oMassProps.Mass

 

This approach works in R2011, don't know about any newer release.  Sorry, I don't know how to post the code to its own window.

0 Likes