iLogic

iLogic

Anonymous
Not applicable
989 Views
8 Replies
Message 1 of 9

iLogic

Anonymous
Not applicable

I wrote a extremely simple ilogic code with a form to fill in needed information on drawings, but I can't get it to work with another drawing. Do I have to type the user parameters everytime? I did follow another post that said add trigger to rules (think I did correct)

 

iLogicForm.ShowGlobal("Material",FormMode.NonModal)
iProperties.Material = Material
iProperties.Value("Custom", "PropertyName")= DESCRIPTION

 this is the very simple code but I can't get form to work with other models. What did I do wrong. 😞

 

I do have a event trigger that says this should start up

0 Likes
Accepted solutions (1)
990 Views
8 Replies
Replies (8)
Message 2 of 9

mcgyvr
Consultant
Consultant

@Anonymous wrote:

I wrote a extremely simple ilogic code with a form to fill in needed information on drawings, but I can't get it to work with another drawing. Do I have to type the user parameters everytime? I did follow another post that said add trigger to rules (think I did correct)

 

iLogicForm.ShowGlobal("Material",FormMode.NonModal)
iProperties.Material = Material
iProperties.Value("Custom", "PropertyName")= DESCRIPTION

 this is the very simple code but I can't get form to work with other models. What did I do wrong. 😞

 

I do have a event trigger that says this should start up


If you don't have the parameters of Material and DESCRIPTION setup in your other part files it will not work as those values are "null/nothing" so it basically errors out..

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 9

YannickEnrico
Advisor
Advisor
Accepted solution

Create the user parameters and save a new template. That way your files will always have those user parameters

_______________________________________________________________________________________
Intel Core i9-14900KF
64 GB DDR5 6000 MHz
2TB WD_BLACK
RTX A4000
------------------------------
Inventor 2026 Professional
0 Likes
Message 4 of 9

mcgyvr
Consultant
Consultant

What is it you are really trying to do though?

I suspect both your description and material will be different for each part so why even create them as a fixed parameter..

Wouldn't it be better to prompt you to enter the description and select the material or something in your form?

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 5 of 9

Anonymous
Not applicable

I'm not really sure what all I want just learning,

 

I want to have (which it is per model) adding Mat'l Spec and Material to the notes.

 

But I can't get the form to follow from model to model.

 

I have over 50 Mat'l specs that would be nice to have the mat'l linked to Mat'l spec even though several have multiple. Have it populate the notes in the drawing.

0 Likes
Message 6 of 9

Anonymous
Not applicable

Would I save this little code under Global Forms? Or Regular Forms? External Rules or Rules? I know so many questions Sorry

0 Likes
Message 7 of 9

mcgyvr
Consultant
Consultant

If you want a rule to apply to multiple parts it "can" be a good idea to make it an external rule..

If you ever change it you only need to change it once vs having to edit the code in each and every file..

 

Material should just be picked from the Materials drop down list in all parts.. 

Not sure what your material spec is composed of.. Do you have a few example of what specifically you need to show in the notes?

But I would likely create it as a custom iproperty if its something that couldn't be handled right in the material list itself..

You could just have an external rule with a list of all your available material specs or pull them from an excel file or lots of different ways depending on how set in stone those are/how often that list is updated,etc...

 

Here is one way just creating the list of material specs in your ilogic rule..

Play around and run this in a part then look at the custom iproperty tab 

'Create an array of all of your material specs
Dim CustMatl As New ArrayList
CustMatl.Add("SPEC 1")
CustMatl.Add("SPEC 2")
CustMatl.Add("SPEC 3")


Try
'attempts to set the value.. If custom field not found it errors out, creates the property and tries again
iProperties.Value("Custom", "MATERIAL_SPEC") = InputListBox("MATERIAL", CustMatl, iProperties.Value("Custom", "MATERIAL_SPEC"), Title := "Material Spec", ListName := "Material Spec")
Catch
' Assume error means the property was not found 
'define custom property collection
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
'create the custom property
oCustomPropertySet.Add("", "MATERIAL_SPEC")
'set the custom property value
iProperties.Value("Custom", "MATERIAL_SPEC") = InputListBox("MATERIAL", CustMatl, iProperties.Value("Custom", "MATERIAL_SPEC"), Title := "Material Spec", ListName := "Material Spec")
End Try

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 8 of 9

Anonymous
Not applicable

WOW I think I just got confused as I'm so new to this part of Inventor that I think it is more complicated than I thought. I know for you about 10 minutes of work for me oh about 1 year.

0 Likes
Message 9 of 9

Anonymous
Not applicable

It is also worth noting that some ilogic codes triggered from your form will not work from model to model, or drawing to drawing. The form needs closing and reopening in each model or drawing.

If ilogic had a close form code that would be better.

I have an itrigger that runs an ilogic rule that opens the form for each new/activated model/drawing, but only if i have manually closed the form in the previous model/drawing.

Although if, as mentioned before, you have the rule as an external rule, then you can right click it in the ilogic browser and run it in any model/drawing and it will make your changes.

Hope this helps.

0 Likes