write part properties to drawing properties

write part properties to drawing properties

Geertvdheide92
Enthusiast Enthusiast
601 Views
6 Replies
Message 1 of 7

write part properties to drawing properties

Geertvdheide92
Enthusiast
Enthusiast

Hi all, 

 

I have a problem with the drawing properties updating after modifying a part. 

When i create a copy design of a sheet metal part and copy the drawing with it, then modify the part, the flat pattern dimensions are not writen to the drawing properties.

in short i want to write all custom properties that are in my part to my drawing file's custom properties.

 

i know there are different solutions for this and there is an answer on the autodesk knowledge page, but i have a problem with my code that i thought would be simple. 

first i will show the code and then explain the problem

Dim Drawdoc As Document = ThisApplication.ActiveDocument
If Drawdoc.DocumentType = kDrawingDocumentObject Then
	
	
	Dim Modeldoc As Document = Drawdoc.ReferencedDocuments.Item(1)
	Dim Modelname As String = Modeldoc.FullFileName	

	Dim ParaNom As Integer = Modeldoc.PropertySets("Inventor User Defined Properties").Count
	For a = 1 To ParaNom
		Dim ModelDesc As Object = Modeldoc.PropertySets("Inventor User Defined Properties").Item(a)
		Dim Propname As String = ModelDesc.displayname	
		Dim DrawDesc As Object = Drawdoc.PropertySets("Inventor User Defined Properties").Item(Propname)
		MsgBox(DrawDesc.displayname)
		
		DrawDesc.Value=ModelDesc.Expression
	Next
End If

what i think i'm doing is taking the name of a property in the part, then using that name to call the same property in the drawing. 

in this case the Propname is always a string. messageboxes work when i fill in propname.

When i call the drawing property with an integer (a) it also works. 

I can not use the same counter because item 1 in the part does not have to be item 1 in the drawing.

 

Referenced file can always be 1 because this only happens for part drawings, i can build in a check for this.

Properties that are in de part will always be also in the drawing file, because these are made when the drawing is created. (this company has mulitple codes running in the background)

 

Does anyone know why i cannot use this way of calling a property?

 

kind regards, 

 

Geert

0 Likes
Accepted solutions (1)
602 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @Geertvdheide92Here is a link to one of my contribution posts that may help you out here.  Also, to update other standard iProperties that you may be automatically be copying from the model to the drawing, you can use the built-in tool for that called 'Update Copied Properties' on the Manage tab of your drawing.

WCrihfield_0-1639498698702.png

That tool will only work if you have things within the Tools tab > Document Settings > Drawing tab > Copy Model iProperty Settings... set-up properly.

WCrihfield_0-1639498871472.png

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

Geertvdheide92
Enthusiast
Enthusiast

@WCrihfield  I already read your post, that's why i mentioned i know there are solutions out there 😉

While doing this it turned from finding a solution to wondering why the ilogic code doesn't work. 

 

maybe that was not clear in my explanation, or maybe this was not posted in the right section. 

 

mainly the question is, why can i not call a property with variable? is there something i need to do to make this work?

 

on the other hand i appreciate your reply and i can work to a solution with the info you gave. 😉

 

kind regards,

 

Geert

0 Likes
Message 4 of 7

Geertvdheide92
Enthusiast
Enthusiast

okay, so i kept looking a bit, and i found that the newer drawings do update these properties. 

the older drawings don't have the copy model iporperties  settings not set correctly.

Is there a way, just like application options, to import document settings?

if there is a way to copy document settings from the newest template to older (copied) drawings they should also work in the newest workflow. 

 

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Geertvdheide92.  I have never seen or heard of a way to export then import drawing document settings from one drawing to another.  There are only a limited number of those settings that are accessible by code too, so some settings may be 'copy-able' from one open document to the other directly through a one setting at a time copying process by code.  Also, I still have not seen a way to access that "Copy Model iProperty Settings" dialog in a drawing document, so you can individually chose which ones to copy by code either.  The only setting that comes close to this is the one called 'DrawingSettings.CustomPropertySourceFile'.  You can get to that setting through DrawingDocument.DocumentSettings.CustomPropertySourceFile.  But it is just for specifying a source model file, not for specifying which individual, specific properties to copy.

 

A thought in the back of my mind is about the possible process of generating a new local rule within those older drawing documents that will copy those needed properties over for you, without having to use that document settings route.  Then putting that new local rule into the Event Triggers settings under some event like 'After Open Document', but that would require a lot of complex code.  There are posts within my contribution posts that show how to create a new local rule within another document, and how to copy rules and/or event triggers settings from one document to another, but I don't know if you would want to get into all of that complexity if this situation is just a minor annoyance.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 7

Geertvdheide92
Enthusiast
Enthusiast

thanks for the response 🙂 

sad to hear there is not an option for this available. i can imagine that would be a welcome option, because to get rid of older files will take a long time.

 

i think indeed any possible solution would be too much work for the problem it needs to solve.

The solution will be copying the properties that are in the company standard vault view lay-out. 

Think about to do this with a global rule, and indeed just doing it with an event trigger.

 

thanks anyway for thinking along with me 🙂

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

This is not a proposed solution, but just another thought along the same subject line, that does not involve any code, that you may or may not be interested in.

https://knowledge.autodesk.com/support/inventor/troubleshooting/caas/sfdcarticles/sfdcarticles/Inven... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes