iLogic not being logical

iLogic not being logical

Anonymous
Not applicable
483 Views
4 Replies
Message 1 of 5

iLogic not being logical

Anonymous
Not applicable
'When case is master model
If master = 0 Then
iLogicVb.RunExternalRule("Inca X - System - Hinge Support Arm.txt")

'When case is job specific
ElseIf master = 1 Then
iLogicVb.RunExternalRule(""&(Left(iProperties.Value("Project", "Part Number"),6))&"-Inca X - System - Hinge Support Arm.txt")

End If

I have this rule triggered when the file is opened. In this instance the "master" parameter within the part is set to 1. So it should run the last external rule.

The problem I've got is when the rule runs from opening it tries to run the first external rule that should only run when "master" is set to 0. If I right-click the 'Run Rule' manually I get the same result:

Capture.JPG

The strange thing is, when I right-click 'Edit Rule' & immediately click OK (without changing any of the code) it runs the correct external rule. After this I can close the file, open it up again and it's works perfectly every time.

For additional info, if I right-click 'Edit Rule', click Cancel & then try to run the rule manually I get the error above. So it's like it only wants to read the value of my "master" parameter correctly after I've ran the rule through the edit rule dialog box! WHY?? Smiley Frustrated

0 Likes
484 Views
4 Replies
Replies (4)
Message 2 of 5

Owner2229
Advisor
Advisor

Hi. So, you mean to say that iLogic is iLogical? 😉

 

First, you should have your rules saved with ".iLogicVb" extension. Otherwise Inventor might not be able to see them, as ".iLogicVb" is the default rules' extension.

Or you can change the default extension in iLogic settings.

 

Second, you can call your external rules with absolute path, so it will be something like:

 

iLogicVb.RunExternalRule("C:\MyFolder\Inca X - System - Hinge Support Arm.iLogicVb")

 You can give it a try, maybe it'll help.

 

Third, is the long rule name needed? Also the spaces. It's way clearer when it's simple.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 5

Anonymous
Not applicable

That would have been a better thread title Smiley Very Happy

 

I have them stored as txt files just now due to the way our system is set up. We have master design files we copy from and the external rules copy with them to become job specific. Therefore, I don't have an external rule directory specified, the rules are stored within the same folder as the part they apply to, which has been working fine until now.

 

Maybe this could work the same way with the extension being set to iLogicVb, but I don't see the need as it should work with txt files and I've gone to a lot of bother to attach the txt files to each master part so that they copy with it. How do I save a rule with iLogicVb extension and store it in the folders I want?

 

As for the filepath, it becomes different for every part after the master design has been copied, depending on the job number. But as they are stored within the same folder as the part, I shouldn't need to set any filepath for it to search in.

According to Autodesk website:

iLogic looks for external rule files in the following order:

  • The folder in which the current Inventor document is located (allows models to be copied with associated rules).

See below a typical copy design of one of our parts.

Capture.JPG

 

0 Likes
Message 4 of 5

Owner2229
Advisor
Advisor

Extension ".iLogicVB" has nothing to do with the code formating, so you can simply rewrite the file's extension.

 

Considering you have your rules stored in the same folder as the part, you can try this, even with the ".txt" extension:

 

iLogicVb.RunExternalRule(ThisDoc.Path & "\Inca X - System - Hinge Support Arm.txt")

And for the second rule:

 

iLogicVb.RunExternalRule(ThisDoc.Path & "\" & Left(iProperties.Value("Project", "Part Number"),6) & "-Inca X - System - Hinge Support Arm.txt")

 

Btw. As the rules are file-specific, why don't you save them as internal instead?

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks, I'll give the ThisDoc.Path a try and post the results

 

I originally had them setup as internal rules, but in some instances there are quite a few files that share the same rule. I was finding that any time I needed to update a rule it was taking a long time to go through each part. Setting it up this way means I only need to update the master rule file if a change is needed, rather than opening up each part and changing it's internal rule.


 

0 Likes