Could someone Please š modify the code below to use a custom i-property <MARK> in place of the ("Part Number")
and remove the ("Description")
thanks in advance.
Sub Main
If TypeOf ThisDoc.Document Is DrawingDocument Then
Dim dwgDoc As DrawingDocument = ThisDoc.Document
For Each dwgSheet As Sheet In dwgDoc.Sheets
If dwgSheet.DrawingViews.Count > 0 Then
modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName
modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument
prtNumber = modelDoc.PropertySets("Design Tracking Properties").Item("Part Number").Value & " - " & _
modelDoc.PropertySets("Design Tracking Properties").Item("Description").Value
If Not String.IsNullOrEmpty(prtNumber) Then
dwgSheet.Name = prtNumber
End If
End If
Next
End If
End Sub
Solved! Go to Solution.
Solved by JhoelForshav. Go to Solution.
Here is a list of all properties and a few samples.
https://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html
Assuming MARK is coming from the model you can do this.
Create a new variable called Mark then change the property set name to āInventor User Defined Propertiesā then change the property your targeting and your done.
Mark = modelDoc.PropertySets("Inventor User Defined Properties").Item("MARK").Value
Delete prtNumber and itās associate lines and insert the above piece of code and then change Mark wherever prtNumber appears.
Alen,
Thank you for your reply, I zero experience with i-logic could you possibly edit the code or high light the text that needs to be removed and where i need to insert the text you suggested.
I would appreciate any help you have to offer.
thanks, Ed
Try this @estewart3E8B6
Sub Main If TypeOf ThisDoc.Document Is DrawingDocument Then Dim dwgDoc As DrawingDocument = ThisDoc.Document For Each dwgSheet As Sheet In dwgDoc.Sheets If dwgSheet.DrawingViews.Count > 0 Then modelFile = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument mark = modelDoc.PropertySets("Inventor User Defined Properties").Item("MARK").Value If Not String.IsNullOrEmpty(mark) Then dwgSheet.Name = mark End If End If Next End If End Sub
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Thank You for your reply. I received the following,
Error in rule: SHEET RENAME 2, in document: KING POST ARRANGEMENT.idw
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at ThisRule.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
You didn't attach all the necessary files. Theres a derived part and some image for the drawing that these files reference as well. I did manage to open the drawing and part by skipping these references though, and it works fine for me...
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
However, that error message would show if the custom property "MARK" doesn't exist in the model document. Try this code instead that gives you a warning if the property doesn't exist š
Sub Main If TypeOf ThisDoc.Document Is DrawingDocument Then Dim dwgDoc As DrawingDocument = ThisDoc.Document For Each dwgSheet As Sheet In dwgDoc.Sheets If dwgSheet.DrawingViews.Count > 0 Then modelDoc = dwgSheet.DrawingViews(1).ReferencedDocumentDescriptor.ReferencedDocument Try mark = modelDoc.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}").Item("MARK").Value Catch MsgBox("The custom property ""MARK"" doesn't exist in the part " & modelDoc.FullFileName) End Try If Not String.IsNullOrEmpty(mark) Then dwgSheet.Name = mark End If End If Next End If End Sub
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
Thanks again, did you run the SHEET RENAME 2 Rule, or the SHEET RENAME which uses the "Part Number" Not <Mark>.
Could you please attach the files that work for you.
Ed
Can't find what you're looking for? Ask the community or share your knowledge.