Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results forĀ 
ShowĀ Ā onlyĀ  | Search instead forĀ 
Did you mean:Ā 

Sheet Rename i-logic

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
estewart3E8B6
473 Views, 7 Replies

Sheet Rename i-logic

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

7 REPLIES 7
Message 2 of 8
A.Acheson
in reply to: estewart3E8B6

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. 

 

If this solved a problem, please click (accept) as solution.ā€Œā€Œā€Œā€Œ
Or if this helped you, please, click (like)ā€Œā€Œ
Regards
Alan
Message 3 of 8
estewart3E8B6
in reply to: A.Acheson

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

Message 4 of 8

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
Message 5 of 8

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)

Message 6 of 8

@estewart3E8B6 

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...

Message 7 of 8
JhoelForshav
in reply to: JhoelForshav

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
Message 8 of 8

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.

Post to forums  

Autodesk Design & Make Report