Mass from Specific Model State to Custom Drawing Property

Mass from Specific Model State to Custom Drawing Property

jtylerbc
Mentor Mentor
215 Views
2 Replies
Message 1 of 3

Mass from Specific Model State to Custom Drawing Property

jtylerbc
Mentor
Mentor

We have existing code that copies the Mass property from the ModelDocument in a drawing. 

It gets rounded according to some cases set up in the rule, then assigned to a custom property in the drawing.

The custom property is then used to populate a value in a sketch symbol. 

 

The code we use to copy the value is the following:

model = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
mass = iProperties.Mass(model) * 2.20462262

 

We're running into a situation where this does not work well.  It turns out this doesn't play nicely with Model States.  Instead of the value of the Model State actually used in the drawing, we seem to get the mass of the Model State that the model was last saved in.

 

How can we change this code to either pull the property from a specified Model State name, or from the one actually used in the drawing view?

0 Likes
Accepted solutions (1)
216 Views
2 Replies
Replies (2)
Message 2 of 3

jnowel
Collaborator
Collaborator
Accepted solution

Instead of:

model = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)

try using:

model = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullDocumentName)

the FullDocumentName includes the ModelState if it exists.

0 Likes
Message 3 of 3

jtylerbc
Mentor
Mentor

Thanks,.  That seems to be working. 

 

Could have sworn we tried that yesterday before I made this post.  But maybe we had something else wrong at the time that made it look like it didn't help.  

0 Likes