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: 

iLogic rule

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
d182284
965 Views, 6 Replies

iLogic rule

Hello,   I'm having trouble creating this iLogic rule.  When in a part - i want to be able to change the title of the part.  When in a drawing - i want to be able to change the title of the drawing en then replace the part title with it.  When i launch the rule in a part i get this error (attachment). When i launch the rule in a drawing, it only updates itsel, which is weird because when i launch the rule without "If doc.DocumentType = kDrawingDocumentObject Then" it works just fine. Any help is welcome.    Rule:  doc = ThisDoc.ModelDocument  Title = InputBox("Enter the title", "Title", iProperties.Value("Summary", "Title"))  iProperties.Value("Summary", "Title") = Title  If doc.DocumentType = kDrawingDocumentObject Then  aModel = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)  iProperties.Value(aModel, "Summary", "Title") = iProperties.Value("Summary", "Title")  End If  InventorVb.DocumentUpdate()    Thanks in advance,  Stan 
6 REPLIES 6
Message 2 of 7
ChristinaForest
in reply to: d182284

Hi!

 

I'm not sure if i understand exactly what you want?

 

add your files here!  ipt and idw

Message 3 of 7
d182284
in reply to: ChristinaForest

I want to be able to change the title of a drawing or part with this one rule. The rule is not for one specific part or drawing, but for basicly all the drawings we have. I'll attach two examples. So I want to be able to do these:

  • When I'm in a drawing and i run the rule: it filles in the Title (iProperties) and then copies the title to the linked part. 
  • When I'm in a part and i run the rule: it just filles in the Title. Nothing more. 

Problem is, when i run the rule from the part i get this message (attachment). 

Message 4 of 7
rjay75
in reply to: d182284

It's because you were using ThisDoc.ModelDocument which in a drawing document returns the part of the first baseview in the document. Use ThisDoc.Document instead.

 

doc = ThisDoc.Document
Title = InputBox("Enter the title", "Title", iProperties.Value("Summary", "Title"))  
iProperties.Value("Summary", "Title") = Title  
If doc.DocumentType = kDrawingDocumentObject Then  
	aModel = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)  
	iProperties.Value(aModel, "Summary", "Title") = iProperties.Value("Summary", "Title")  
End If  
InventorVb.DocumentUpdate()

 

Message 5 of 7
d182284
in reply to: rjay75

Thanks, it's working in the drawing now. But if i run it in a part it still comes up with the error message.
Message 6 of 7
rjay75
in reply to: d182284

Missed a line. This should use ThisDoc instead of ThisDrawing.

 

doc = ThisDoc.Document
Title = InputBox("Enter the title", "Title", iProperties.Value("Summary", "Title"))  
iProperties.Value("Summary", "Title") = Title  
If doc.DocumentType = kDrawingDocumentObject Then
    aModel = IO.Path.GetFileName(ThisDoc.ModelDocument.FullFileName)  
    iProperties.Value(aModel, "Summary", "Title") = iProperties.Value("Summary", "Title")  
End If  
InventorVb.DocumentUpdate()
Message 7 of 7
d182284
in reply to: rjay75

Thanks a lot! And i understand what the problem was so that helps me getting furthur with iLogic, so that's great.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report