Note: This article is written and published in Ukrainian and is a translated version of the original published here.
1. Entry
In the previous parts, we got acquainted with the basics of iLogic, collected data types, variables, conditional constructs and even learned how Snippets help to quickly automate routine actions. But there is one problem: even the most convenient rule remains "closed" for those who do not want or do not know how to work with code.
This is where another iLogic tool comes into play —Forms. These are visual forms of control that allow you to interact with options and rules without opening the editor. You create a clear interface — and anyone can change model parameters, run scripts, or manage components without even knowing that programming is happening inside.
In this part, we'll look at how Forms make things easier when they're especially useful, and how to create your first form in iLogic.
2. What are Forms
A Form is a window with a set of cells and buttons for convenient use of parameters, properties and, accordingly, iLogic rules. With the help of the form, you can create a convenient editing window with your parts and assemblies.
Forms, like rules, are internal and external.
- internal forms are most often used to place the most necessary parameters and properties of the current document in one window, and sometimes internal rules are added;
- external forms are used to create a kind of separate panel for external iLogic rules. This allows you to use external rules more skillfully.
Pros and cons The use of external and internal forms is similar to the rules. The path of creation must be chosen by circumstances.
3. How to create a form
If you have already read the first part of the iLogic Without Fear blog, namely the section on creating rules, then there will be nothing new and complicated for you in the process of creating forms. As in the case of rules, you should first enable the iLogic module, then go to the Forms section and right-click (RMB) on an empty field and selectAdd Form.
Now you see in front of you the editor of your first form, which consists of:
- Preview your form. The window only serves to visually observe the current edit of your form;
- Form editing window, which can be divided into 4 parts:
- Field for convenient retrieval of parameters, rules and properties of the current document;
- A field with typical building blocks for building your form. For example: Group - divides the form into sections, Tab Group - combines your parameters/properties into a separate group in the current section, Picture - allows you to set the image in the space of your form, etc.;
- A field to place your parameters, properties, rules, or building blocks by dragging and dropping from fields A and B;
- field to edit the properties of the display style of elements from field C.
4.Examples of use
I propose, as an example, to create a dynamic pipeline, which will consist of a self-created pipe part and 2 flanges. Among the parameters, we will have the conditional diameter and length of the pipe. So let's get started:
- First, let's create a standard part in the form of a round pipe (dimensions are not important);
- Let's create an assembly and place a round pipe in it. So far, we do not tie, but place 2 flanges from the white library of components in our assembly. I placed the flange according to the standardDIN EN 1092-1 Welding Neck Flange Type 11 - PN 10 , the size does not matter, it is important for us that these flanges are placed as standard (As Standard). Do not forget to connect all the elements and save the assembly;
- Now in the assembly we need to create parameters, which later we will place in the mold and control our dynamic pipeline block. Create a piping length parameter and a drop-down text list parameter;
For training there, 4 diameter options are enough, but you are not limited in the depth of creating your cases.
- Now we need to write logic in the form of an internal iLogic rule in the assembly. So we create a rule and write the following logic:
Dim d_TF As Double
Dim sSizeFlange As String
Select Case sDN
Case "DN10"
Parameter("Трубка:1", "d1") = 17 'Зовнішній діамтр
Parameter("Трубка:1", "d0") = 2 'Товщина стінки
sSizeFlange = "10 x 17.2"
d_TF = 35
Case "DN15"
Parameter("Трубка:1", "d1") = 21.3 'Зовнішній діамтр
Parameter("Трубка:1", "d0") = 2 'Товщина стінки
sSizeFlange = "15 x 21.3"
d_TF = 38
Case "DN20"
Parameter("Трубка:1", "d1") = 26.9 'Зовнішній діамтр
Parameter("Трубка:1", "d0") = 2.3 'Товщина стінки
sSizeFlange = "20 x 26.9"
d_TF = 40
Case "DN25"
Parameter("Трубка:1", "d1") = 42.4 'Зовнішній діамтр
Parameter("Трубка:1", "d0") = 2.6 'Товщина стінки
sSizeFlange = "32 x 42.4"
d_TF = 42
End Select
Dim flange1 = Components.AddContentCenterPart("DIN EN 1092-1 Welding Neck Flange Type 11 - PN 10 10 x 17.2:1",
"Tube & Pipe:Fittings:Flanges",
"DIN EN 1092-1 Welding Neck Flange Type 11 - PN 10",
sSizeFlange)
Dim flange2 = Components.AddContentCenterPart("DIN EN 1092-1 Welding Neck Flange Type 11 - PN 10 10 x 17.2:2",
"Tube & Pipe:Fittings:Flanges",
"DIN EN 1092-1 Welding Neck Flange Type 11 - PN 10",
sSizeFlange)
Parameter("Трубка:1", "d2") = dLength - (d_TF * 2) 'Довжина трубки
In this code, I want to draw your attention to the parameters d1, d2 and d0 in the element The tube is the outer diameter, length and wall thickness, respectively. Next, you should pay attention to the method of replacing an element from the component library. It occurs through the snippet Components.AddContentCenterPart(), it can be downloaded from the iLogic Assemblies/Components section, respectively, or in a faster way by right-clicking on the element in the browser and selecting the following:
* - Unfortunately, iLogic cannot always generate a snippet automatically, in this case I wrote the path to the file manually.
And finally, we need to explain what happens in the last line, where we adjust the length of the tube using a formula. This formula is necessary to compensate for the thickness of the flanges, which change their size from different types.
- And finally, we can move on to creating our first (or not) shape.
Perform the steps from the previous section "How to create a form" and from field A (parameters/properties) drag our parameters (dLength and sDN) to field C. You can get something like this:
Next, I propose to perform a simple edit of our parameters in the field D. For example: change the name and font.
After I finished editing the form, I got a pipeline editing window like this:
5. Conclusion
Forms in iLogic is a bridge between complex model settings and user-friendly controls. They allow you to hide the code, but leave all the automation capabilities at hand in the form of buttons, fields and lists.
With forms, you can make working with parameters fast, error-free, and understandable even for those who have never written a single line of code. And most importantly, you decide which controls you need and how they look.
Try adding the Part Number property of the document to our example, but in read-only view. And the text in this cell will write the iLogic rule. For example: Pipeline DN25, L=400.
Previous publications can be found at the links:
Note: This article is written and published in Ukrainian and is a translated version of the original published here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.