Ilogic. If Parameter exist, run external rule

Ilogic. If Parameter exist, run external rule

vkulikajevas
Advocate Advocate
1,077 Views
6 Replies
Message 1 of 7

Ilogic. If Parameter exist, run external rule

vkulikajevas
Advocate
Advocate

I want to create a Rule:

 

If Parameter Thickness exist, Then Run External Rule name "extrule". If it doesn't, then do nothing.

 

Can you please help me with syntax? I tried many options with catch and try, but it does not work

0 Likes
Accepted solutions (2)
1,078 Views
6 Replies
Replies (6)
Message 2 of 7

Sergio.D.Suárez
Mentor
Mentor

Hi, I think you're talking about a metal sheet part. I think you could implement a code as below. If it is a metal sheet part, the thickness will return, if it is not a metal sheet part, the code will do nothing.

Dim doc As Document = ThisDoc.Document

Try
Dim oThick As Double = Round(doc.componentdefinition.thickness.value,2)
MessageBox.Show(oThick)
Catch
End Try

 I hope this can help you to solve your problem. Regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 3 of 7

JhoelForshav
Mentor
Mentor
Accepted solution

If it's about wether or not the document is a sheet metal part as @Sergio.D.Suárez said, then this rule should work for you 🙂

 

Const SheetMetalSubtype =
"{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"
If ThisDoc.Document.SubType = SheetMetalSubtype Then iLogicVb.RunExternalRule("extrule")

Message 4 of 7

vkulikajevas
Advocate
Advocate
Sergio.D.Suárez,  thank you for your reply. 
But i need to convert solid body template into Sheet metal, and enter that Thickness in Stock Number column (But only if Thickness parameter exists!).
 
I thought of using formula with a trigger on saving the file:
If Thickness exist Then 

 

iProperties.Value("Project", "Stock Number") = "t = " & Thickness & " mm"

If else 

do nothing.

I don't need anything written in Stock Number if there is no thickness in the template (i.d. it is not a sheet metal).

Maybe you have any advice on this?

 

 

0 Likes
Message 5 of 7

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

This might serve. If it is metal sheet, add the field to the property (check that the unit "mm" is suitable) Then add the event for example before saving the document or before any change of the geometry.

Note that if the part is not metal sheet, it will erase the field. In case the part has been changed from metal sheet to normal part, then it will erase the field.

 

Dim doc As Document = ThisDoc.Document

Try
Dim oThick As Double = Round(doc.componentdefinition.thickness.value, 2)

iProperties.Value("Project", "Stock Number") = oThick & " mm"

Catch
iProperties.Value("Project", "Stock Number") = ""
End Try

 I hope this works for your problem. Regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 6 of 7

vkulikajevas
Advocate
Advocate

I don't really understand why, but this Round syntax changes the dimension (example from 12 mm to 1.2 mm)

0 Likes
Message 7 of 7

Sergio.D.Suárez
Mentor
Mentor

That's why I said you should control the unit. The default Internal Inventor unit is the "cm" to correct it, you can simply multiply it by a correction factor and have the desired value. This is a very safe way because it takes the parameter directly, it does not matter the language in which you work, nor does it matter if the name has changed to the parameter, for example if you have placed "Gauge". Generally I use this type of access for metal sheet. Regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes