Ilogic from/rule to activate Standard in IDW

This widget could not be displayed.

Ilogic from/rule to activate Standard in IDW

Anonymous
Not applicable

Hello,

 

I am using a template with two different standard (regarding view preferences).

can i run a rule which i can add to a form, to select/activate the standard ?

 

sheet sizes are all the same, its only about activating the standard via a form.

 

Saltlife212_0-1592208927934.png

 

 

regards.

 

0 Likes
Reply
Accepted solutions (1)
1,036 Views
9 Replies
Replies (9)

WCrihfield
Mentor
Mentor

Yes.  Any iLogic rule can be added to an iLogic form.  It will show up as a button on the form.  When you click that button it will run the rule.

I'm not sure exactly what you are wanting to do here though.

Do you want to open a form, click this rule button, and the rule will change which Style Standard is activated within the open drawing?  Do you want to see the names of the Standards, or just a simple toggle between the only two available?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

WCrihfield
Mentor
Mentor

Hi @Anonymous 

Would this iLogic code work for your situation?

It starts by checking to make sure the active document is a drawing file.  If not it ends the rule, because it won't work on any other type of file.

Then it gets the active drawing standards style.

Then it compares the name of that current style with item #1 of the list of that type of (local) styles.

If they are the same, that means the current style is the first style in the list, so it changes to the second style in the list.  If the names didn't match, that means the current style is the second one in the list, so it changes to the first style in the list.

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
'Dim oAStd As DrawingStandardStyle = oDDoc.StylesManager.ActiveStandardStyle.PresetTextHeights
Dim oAStd = oDDoc.StylesManager.ActiveStandardStyle
If oAStd.Name = oDDoc.StylesManager.StandardStyles.Item(1).Name Then
	oDDoc.StylesManager.ActiveStandardStyle = oDDoc.StylesManager.StandardStyles.Item(2)
Else
	oDDoc.StylesManager.ActiveStandardStyle = oDDoc.StylesManager.StandardStyles.Item(1)
End If

 

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Anonymous
Not applicable

Hi @WCrihfield 

 

i was thinking more in the direction of having a Form, with in it 2  Buttons in which the user can select the desired style.

but now i am seeing it is not that simple to add selection buttons to form only text or parameters field if i am not mistaking.

 

 

0 Likes

WCrihfield
Mentor
Mentor

OK. So you would like one button to have the name of the one style on it, and if you click that button, it switches to that style (if not already active).  Then the second button has the name of the second style's name, and when clicked, switches to that style.  It that what you had in mind?

 

That is possible, but those buttons would have to represent (and run) iLogic rules, which make the change happen.  The only other buttons you can put on a normal iLogic form are Done, OK, Cancel, Apply, or none.

 

Or instead of two buttons, you could use a single multi-value parameter with the names of those styles in it.  Then have the user select which one they want using either a drop-down list or a two-option radio button control.  But either way, you will still have to have an accompanying iLogic rule to make the changes in the background, based on your selection, in this situation.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Anonymous
Not applicable

Yes correct

0 Likes

WCrihfield
Mentor
Mentor
Accepted solution

OK.  I've created the two button version, where both the rules and the form are local (saved within the drawing document).  These should work if the rules are external and form is global form too, if set up right.

Rule 1 (I named it "Shop Drawings")

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSStyle As DrawingStandardStyle = oDDoc.StylesManager.StandardStyles.Item("A._Shop_Drawing.")
oDDoc.StylesManager.ActiveStandardStyle = oSStyle
InventorVb.DocumentUpdate()

 

Rule 2 (I named it "Other Drawings")

 

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("This rule '" & iLogicVb.RuleName & "' only works for Drawing Documents.",vbOK, "WRONG DOCUMENT TYPE")
	Return
End If

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSStyle As DrawingStandardStyle = oDDoc.StylesManager.StandardStyles.Item("B._Others.")
oDDoc.StylesManager.ActiveStandardStyle = oSStyle
InventorVb.DocumentUpdate()

 

As for the Form:

  • After you have created both of the above rules.  Create a new Form.
  • In the upper-left pane of the Form Editor, select the Rules tab.
  • Now drag both of your rules over onto the Form Editor's right side pane.
  • Now, in that upper-right pane, select and change "Form 1" (or Form 2, etc.) to whatever you want to call your form.
    • This will be the visible name of the form on the Forms tab of your iLogic browser pane.
  • With that top row in the upper-right pane selected (but not still editing the name), change the "Predefined Buttons" setting (in the lower-right pane) to None (to simplify, since we already have two buttons for the rules).
  • Now select the first rule line item (in the upper right pane), and change its "On Click Action" setting (under "Behavior" properties) to "Close and then Run Rule".
  • Do the same for the second rule line item.
  • Now, if you want, for clarity, you can drag a "Label" from the lower-left pane, over just above the two rule buttons, and change its text to say something like "CHOOSE DRAWING TYPE".

Now your form editor (and form) should look something like the image below.

Form Editor screen shot 1.png

 

Now click OK on the Form Editor.

Now you should be able to click on that form on your iLogic Forms tab, and it will launch a form similar looking to the one above, and when you click one of the buttons, it will run the associated rule, which will change the Active drawing standard style to the one you want.

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Anonymous
Not applicable

Hi @WCrihfield 

 

thank you very much, i got it to work.

 

only i had to remove the second line from the rule, it gave me an error:

Saltlife212_0-1592336881984.png

 

but other than that it is working like i hoped for.

 

thanks again!

 

any tips or idea how to get this, or an ilogic form in the inventor ribbon such as user commands ?

i am able to get a rule in here as a button, but still not a command button in the ribbon that launches the corresponding ilogic form.

such as this

Saltlife212_1-1592337108727.png

 

0 Likes

WCrihfield
Mentor
Mentor

Sure. Since you already know how to run an iLogic rule using a VBA Macro, it's basically the same thing.  You would create a simple iLogic rule that shows the form by using one of the following lines of code.

iLogicForm.Show("Form 1")
iLogicForm.Show("Form 1", FormMode.NonModal)
iLogicForm.Show("Form 1", FormMode.Modal)
iLogicForm.ShowGlobal("Form 1")
iLogicForm.ShowGlobal("Form 1", FormMode.NonModal)
iLogicForm.ShowGlobal("Form 1", FormMode.Modal)

By the way these lines of code can be found within your iLogic Rule Editor, on the System tab, of the Snippets, under the Forms topic.  You would only need one of these lines.  If your form is a local form (saved within the document), then you would use one of the iLogicForm.Show() functions.  But if your form is a Global form, you would obviously use one of the iLogicForm.ShowGlobal() functions.  Modal means that it will stay open even when doing other things outside of the form.  NonModal means it will close if you try do other things outside of the form.

This sort of thing almost always works better with external rules & global forms though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

WCrihfield
Mentor
Mentor

If you want the button to be in a different place in the ribbon (other than the default "User Commands" panel), you will need to place the button by code.  To do that you'll have to 'climb down the ladder' of the Object Model of Inventor to that location.  Are you familiar with the Object Model?  It shows you all the main objects and the hierarchy of all the main objects within Inventor's API system, similar to a road map, showing you where you have to go with your code to get to a certain object.

It all starts with the UserInterfaceManager (ThisApplication.UserInterfaceManager), then the specific Ribbon, then the specific RibbonTab, then the specific RibbonPanel, then its CommandControls (then possibly ChildControls, and/or SlideoutControls, and/or the SlideoutControl's ChildControls).  Once you've got that location, you then need to get the macro's command's MacroControlDefinition, from ThisApplication.CommandManager.ControlDefinitions.Item("YourMacro'sName").

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes