Copy I properties model to drawing

Copy I properties model to drawing

didin.suryadi6JREK
Advocate Advocate
2,313 Views
6 Replies
Message 1 of 7

Copy I properties model to drawing

didin.suryadi6JREK
Advocate
Advocate

Hi,

 

I want to copy the model properties "DESCRIPTION" to the drawing. What i-logic code could be work?

 

Please help.

copy iproperties to drawing.JPG

0 Likes
Accepted solutions (2)
2,314 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @didin.suryadi6JREK.  The settings you are showing within your screen captured images are not accessible by iLogic code, but iLogic code can definitely copy that 'Description' iProperty from the model to the drawing for you.

Here is a very simple iLogic rule code that you can try:

Dim oMDoc As Document = ThisDrawing.ModelDocument
If Not IsNothing(oMDoc) Then
	iProperties.Value("Project", "Description") = iProperties.Value(oMDoc.DisplayName, "Project", "Description")
End If

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

didin.suryadi6JREK
Advocate
Advocate

Hi

 

Thanks, It's still didn't work and the error msgs came up like below:

didinsuryadi6JREK_0-1632275948144.pngdidinsuryadi6JREK_1-1632275978496.png

 

Please advise

 

Rgds

 

 

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor
Accepted solution

OK.  Sometimes those iLogic snippets can be the right tool for the job, and other times it's best to do things the traditional longer way, to be sure.  Here is another, more robust iLogic rule you can try.  It first makes sure that the 'active' document is a drawing, because this rule is designed to work with a drawing document.  If it passes that test, it captures that drawing document object.  Then it looks for a reference to a 'Model' document.  The 'Model' document is usually the first document being referenced within the drawing document.  If it doesn't find one, it will let you know, then exit the rule.  If it finds one, it captures that model document object.  Then it retrieves the Description iProperty value from that model document.  Then it checks to see if it returned anything.  If it was empty, it will let you know, then exit the rule.  If there was something returned, it then proceeds to set that as the Value of the drawing's Description iProperty.  All done the traditional, long way, with checks included.

Here's the new iLogic rule code:

 

'get the 'active' drawing document (must be ran while drawing is active)
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule to work. Exiting Rule.", vbCritical, "iLogic")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisApplication.ActiveDocument

'get the drawing's 'Model' document
If oDDoc.AllReferencedDocuments.Count = 0 Then
	MsgBox("This drawing does is not referencing a 'Model' document.  Exiting Rule.", vbExclamation, "iLogic")
	Exit Sub
End If
'a Drawing can contain more than one 'Model' document, but the first is always used
Dim oMDoc As Document = oDDoc.AllReferencedDocuments.Item(1)

'get the 'Description' iProperty's Value from the 'Model' document
Dim oModelDesc As String = oMDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value

'check to make sure it contains something
If String.IsNullOrEmpty(oModelDesc) Then
	MsgBox("The 'Model's Description iProperty was empty, so not copying, and exiting rule.", vbInformation, "iLogic")
	Exit Sub
End If

'Set it as the Value of the Drawing's Description iProperty
oDDoc.PropertySets.Item("Design Tracking Properties").Item("Description").Value = oModelDesc

 

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

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

b.mccarthy
Collaborator
Collaborator
Accepted solution

I use this (Kudos to whomever wrote it!):

 

'--------------------------------------------------------------------------------------------------------------------
'Push Part/Assy iProperties to Drawing iProperties

mDoc = ThisDrawing.ModelDocument
partNoProp = mDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number")
iProperties.Value("Project", "Part Number") = partNoProp.Value

stkNoProp = mDoc.PropertySets.Item("Design Tracking Properties").Item("Stock Number")
iProperties.Value("Project", "Stock Number") = stkNoProp.Value

descProp = mDoc.PropertySets.Item("Design Tracking Properties").Item("Description")
iProperties.Value("Project", "Description") = descProp.Value

titleProp = mDoc.PropertySets.Item("Summary Information").Item("Title")
iProperties.Value("Summary", "Title") = titleProp.Value

projProp = mDoc.PropertySets.Item("Design Tracking Properties").Item("Project")
iProperties.Value("Project", "Project") = projProp.Value 
'

'Forces update after rule runs 
iLogicVb.UpdateWhenDone = True
0 Likes
Message 6 of 7

didin.suryadi6JREK
Advocate
Advocate

Thank You Sir, THis is work, 

I have another simple question related to the drawing with i-logic, if you have some time please take a look. below is the link

 

https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/choose-specific-drawing-template-using-...

0 Likes
Message 7 of 7

didin.suryadi6JREK
Advocate
Advocate

Thanks, This one works too.

 

 

0 Likes