iLogic rules not firing

iLogic rules not firing

mslosar
Advisor Advisor
375 Views
2 Replies
Message 1 of 3

iLogic rules not firing

mslosar
Advisor
Advisor

I have an application i'm working with that copies 'template' files from a folder into your working folder and then alters them based on parameters you feed the existing models.

 

I'm having to use ilogic to map a couple features like Part Number. Problem i'm running to is that the rules do not fire.

The original problem is that the basic rule worked just fine - on 'Before Save' i simply had it copy the application PN to the inventor partnumber. Worked just fine. However, users complaint was the rule kept running and they couldn't overwrite the the pn's when needed without entering each affected part and removing the trigger setting, or editing the iproperty value that got mapped. So i tried turning the ilogic into something that just did it's copy once so they wouldn't have to worry about it.

 

I have about 150 different template file and i did not want to go through all and add a counter parameter to them, so i tried to write something that would do the job of seeing if the counter existed, and if it didn't, add it and update the properties. Next pass, it just wouldn't run.

 

Well, the ilogic works - IF i'm already in the part, in inventor, and i manually run the rules. In the copy/update process it does not.  The basic ilogic line of:

 

iProperties.Value("Project", "Part Number") = iProperties.Value("Custom", "MYPartNumber")

 

works fine if that's the entire script. The copy/update process runs and the pn updates fine.  When i change it to:

varPartDoc = ThisDoc.Document
varPartDoc.Update

	'add PNOnce parameter if it doesn't exist
Try
	'Change value of parameter
	Parameter("PNOnce") = "True"
Catch
	'Create Parameter as it doesn't exist but set the values first
	iProperties.Value("Project", "Part Number") = iProperties.Value("Custom", "MYPartNumber")

	varPartDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("PNOnce", False, "BOOLEAN")
End Try

 

That? Simply doesn't run during the copy/update process.  But it runs if i hit 'save' while i have the part number in inventor.

 

Any ideas as to why? Or is it manually add it to all 150ish files?

0 Likes
376 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Still not sure why the original doesn't fire, but i switched modes and went through i property using the below and it <knock on wood> seems to be working as expected now

 

Try
	prop = customPropSet.Item("MyNewName")
	Catch
		prop = customPropSet.Add(-1, "MyNewName")
	Finally
		If prop.Value < 1
		iProperties.Value("Project", "Part Number") = iProperties.Value("Custom", "MyPartNumber")
		prop.Value = prop.Value + 1
		End If
	
	End Try
	   
ThisDoc.Document.Update
0 Likes
Message 3 of 3

WCrihfield
Mentor
Mentor

If you were creating new documents based on templates, instead of 'copying' template files, I would recommend you use the document 'FileSaveCounter' property, if you only want this rule to 'do its thing' one time (when the document gets saved for the first time), then never again.  This would only work with 'new' documents, though,  not with previously existing, copied documents.

There is a way to 'inject' an iLogic rule into other Inventor documents, using an external rule, if that sounds like a plan.

I have used this route many times before.

You could also use a Custom iProperty (or an attribute attached to the document) too, as an alternative to using a Parameter too, if you want to continue using a similar system to the one you are already using.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)