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: 

Setting Event Triggers for standard Content Center parts

4 REPLIES 4
Reply
Message 1 of 5
meGVGMF
206 Views, 4 Replies

Setting Event Triggers for standard Content Center parts

Hello

 

Is there any way to add Event Triggers to standard Content Center parts?

 

Our usecase is we enable tweaking of standard parts to facilitate some of our workflows. To make this editing process more 'hygenic', it would be nice to have some triggers to help tidy the state the file's left in at the end.

 

I can run external rules within the file. I see no reason why I shouldn't be able to set triggers to run those rules for me.

 

Thanks

4 REPLIES 4
Message 2 of 5
WCrihfield
in reply to: meGVGMF

Hi @meGVGMF.  Are you able to edit those parts normally, by opening them in Inventor, make edits/changes that would 'dirty' the document, then use regular save?  Or are they 'ReadOnly', or otherwise un-editable, due to being stored in a 'library' type location?  I have not tried doing what you are asking before, but if you are able to save your edits to those parts, I don't see why adding Event Triggers to them would be a problem.  Are you talking about adding these Event Triggers settings manually, or by code?

 

PS.  I have added Event Triggers settings to documents by code before, and have some resources/links available that might help you with that part, if that is what you want to try out.

Add An iLogic Rule To An Event Trigger Using An External iLogic Rule 

Copy All iLogic Rules & Event Triggers From One Document To Another Using An External iLogic Rule 

How To: "Unhide" the "Hidden" Event Triggers iProperties PropertySet using an iLogic rule 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5
meGVGMF
in reply to: WCrihfield

Hi, thanks for the response!

 

Yes, manually saving works, no problems there, and my thoughts on this are the same as yours.

 

I am talking about adding event triggers manually. But I was thinking I could put the handler in the 'Part Documents' tab, to distribute it automatically to all existing and future files.

 

This is functionality which I'm not sure how to reproduce. Looking quickly over your links, I think I've managed all these things in other applications, but they don't seem to cover assigning these handlers proactively.

 

I've never made an add-in before. Would that be something that might help? Maybe it might be a way of essentially assigning handlers to events occurring outside of the scope of the document itself, that would then assign the relevant ones to the triggers within the document.

 

I just tested it, though, running one external rule to assign another to the BeforeDocSave event that just has a `MsgBox()` statement, and nothing; it seems like it may be strictly impossible to add handlers to these files, which means it would need to be taken care of entirely within the add-in, if any of what I've said about add-ins is even possible.

 

Here's the test code in case I missed something:

 

 

' Test.vb
Sub Main()
	Dim oDoc As Document = ThisDoc.Document
	'Compute BeforeDocSave
	Dim AddRuleParams As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
	With AddRuleParams
		.Add("oDoc", oDoc)
		.Add("ruleName", "Test2")
		.Add("eventType", "BeforeDocSave")
	End With
	iLogicVb.Automation.RunExternalRuleWithArguments(oDoc, "AddExternalRuleToDocument", AddRuleParams)	
End Sub
' Test2.vb
Sub Main()
	MsgBox("BeforeDocSave, Content Center part")
End Sub

 

 

Top snippet is the rule run manually in the context of the Content Center file, and the bottom is the handler that should be assigned. The rule `AddExternalRuleToDocument` that carries out the assignment is a utility that's working perfectly in all other applications, before and since performing the test.

Message 4 of 5
WCrihfield
in reply to: meGVGMF

About to leave for the day, but just wanted to add a little something.  You may already be aware of this, but the settings for all the other Event Triggers that are not scoped to 'This Document' are kept in a single external XML file named "RulesOnEvents.xml".  I know there are ways of editing that document both manually, and by code, but I have honestly not messed with it myself much before, other than simply opening it and looking at it manually.  I don't know if this helps any though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5
meGVGMF
in reply to: WCrihfield

Ah, thanks, but I think that won't work. I've checked into that before and it seems like it's just a reflection of what you find under the general triggers (or vice versa). Maybe there's a way to tell it to target Component Center files, and I'll take a look, but I suspect it's just where that data's kept.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report