iLogic Forms not launching my rule

iLogic Forms not launching my rule

Anonymous
Not applicable
1,592 Views
8 Replies
Message 1 of 9

iLogic Forms not launching my rule

Anonymous
Not applicable

Hello!

 

I have been using an iLogic rule to change the sheet size of my drawing. After the 2021 Inventor installation it seems that I can't launch the rule thru the iLogic forms like it was possible in the 2020 version

 

This is the rule I have been using since. Anybody, smarter than me, have some ideas how to fix it?

 

If Parameter("SheetSize") = "A0" Then
	ActiveSheet.ChangeSize("A0", moveBorderItems := True)
	
ElseIf Parameter("SheetSize") = "A1" Then
	ActiveSheet.ChangeSize("A1", moveBorderItems := True)
	
ElseIf Parameter("SheetSize") = "A2" Then
	ActiveSheet.ChangeSize("A2", moveBorderItems := True)
	
ElseIf Parameter("SheetSize") = "A3" Then
	ActiveSheet.ChangeSize("A3", moveBorderItems := True)
	
ElseIf Parameter("SheetSize") = "A4" Then
	ActiveSheet.ChangeSize("A4", moveBorderItems := True)


End If

iLogicVb.UpdateWhenDone = True
ThisApplication.ActiveView.Fit

 

0 Likes
Accepted solutions (3)
1,593 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

It is working for me, and I am using 2021 software.  Is this rule a local rule within your drawing file, or is it an external rule.  (Looks like an external rule to me.)  Is the form a local form within your drawing file, or is it a global form.  I copied your code to a local rule in a new drawing file, then created a simple local form, and used drag-and-drop to add the rule (which becomes a button) to the form.  Then added the multivalue UserParameter to the drawing files parameters.  Then clicked to launch the form, then clicked the button, and it changed the current drawing sheet size, as expected.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 9

Anonymous
Not applicable

That's how it worked for me before the 2021 upgrade.

I will try to create a new drawing with the user parameters and let you know how it worked out.

0 Likes
Message 4 of 9

WCrihfield
Mentor
Mentor

How recently did you update from 2020 to 2021?  When we updated, it lost several settings.  I had to tell it where my rules were again, by importing a iLogic Configuration XML file I had previously exported from Tools tab / Options panel / iLogic Configuration dialog box.  If you didn't think to save those options, before updating the software, it might have lost your settings.  You may have to specify the 'External Rule Directories' agin within that dialog box.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 9

Anonymous
Not applicable

The update was made yesterday.

Unfortunately thats not the issue. I imported the settings and my other macros work fine. The only problem is with the one indicated in here.

 

 

0 Likes
Message 6 of 9

Anonymous
Not applicable
Accepted solution

Right now it only works if I choose the right sheet size from the dropdown menu and then push the button to activate the rule. In the 2020 version it was enough to just choose the right sheet size from the dropdown menu and the rule launched itself automatically.

 

Any ideas about that 🙂

0 Likes
Message 7 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Again...is this a local rule, or an external rule.  If it is a local rule, change the format of the Parameters from:

If Parameter("SheetSize") = "A0" Then

to

If SheetSize = "A0"

That will cause the rule to run automatically every time the parameter changes.

If your rule is an external rule, what I would do to be more efficient, is create a very simple local rule that just has a 'dummy variable' at the top of it, whose value is set to SheetMetal (without quotes or Parameter()), then the next line will call the external rule to run like this:

iLogicVb.RunExternalRule("External Rule Name")

This will use the same Parameter recognizing auto-run trigger as a local rule, but run your external rule.

I understand that many already created parts may not already have this local rule in them, but there is a fairly easy way to inject this simple local rule into your documents.  I can show you how, if that process sounds good to you.

I use this process alot to reduce having to edit potentially 100's of rules (on in each document) versus editing one instance of it (external rule).

 

As far as the Form goes...I assume it is a Global Form, instead of a local Form.  If so, you can just set it up to launch on 'New Document' or 'After Open Document' in the Event Triggers dialog box (if you haven't already).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 9

Anonymous
Not applicable

Thank you for the aswer!

I got it working as a local rule, but is there a way to make it work as external?

Right now, if external, I have to run the rule manually every time I change the Parameter.

I tried iLogicVb.RunExternalRule("Sheet_Size") command, but it does not work.

Any ideas what I'm doing wrong?

 

0 Likes
Message 9 of 9

WCrihfield
Mentor
Mentor
Accepted solution
  • OK. Try this:
  • 1st make sure this drawing document contains a Text type Parameter called SheetSize, and that all its values are in place.
  • Create a local rule named "Show Form"
  • Paste the following code into that rule, then save it, then close it.
iLogicForm.ShowGlobal("Change Sheet Size")
  • Go to Manage tab / iLogic panel / and click Event Triggers, to open its dialog.
  • On the "This Document" tab, drag and drop the "Show Form" rule over under the "New Document" event, then click OK.
  • Create a local rule.  (Name doesn't matter)
  • Copy and paste the following into that local rule.
oDV = SheetSize
iLogicVb.RunExternalRule("Change Sheet Size")
  • IMPORTANT:  Make sure that "SheetSize" in the first line turns BLUE.  This means that Inventor recognizes it as a local Parameter.
    • If it didn't turn blue, delete the name, then on the Model tab above, click on "User Parameters".  You should see the Parameters tab on the right get filled with the Parameters Names & equations.  With your cursor in the correct place in the code (after oDV = ), double click on the name of the parameter in the Parameters tab.  That should automatically insert the Parameter name into the code window below, where you had the cursor, and is definately should be Blue now.
  • Click the Save button on that rule, then click the Close button, to close it.
  • Create an external iLogic rule named "Change Sheet Size".
    • This name must match the name you specified in the local rule, exactly.
  • Paste your code from your first post into that external rule, then save it, then close it.
  • On the Global Forms tab, right click and choose "Add Form".
  • Immediately change the "Form ##" (first line within the new Form) to "Change Sheet Size".
  • On the Parameters tap (upper left of the Form Editor dialog box), drag and drop that "SheetSize" parameter over onto the empty area below the top line, where you renamed it.  Then click OK.
  • Now, if this was all done in your drawing Template file, you should be able to save, then close this document.
  • Now click on New, to open a new drawing document.
  • It should immediately show the Global Form named "Change Sheet Size".
  • Then when you choose a different size from the drop down list, it should immediately update the size of your sheet, even before you click Apply or OK on the form.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes