Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I want to copy the model properties "DESCRIPTION" to the drawing. What i-logic code could be work?
Please help.
Solved! Go to Solution.
Hi,
I want to copy the model properties "DESCRIPTION" to the drawing. What i-logic code could be work?
Please help.
Solved! Go to Solution.
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
(Not an Autodesk Employee)
Hi
Thanks, It's still didn't work and the error msgs came up like below:
Please advise
Rgds
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
(Not an Autodesk Employee)
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
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
Thanks, This one works too.