Ilogic Rule if flat pattern exists

Ilogic Rule if flat pattern exists

leonque
Enthusiast Enthusiast
1,978 Views
4 Replies
Message 1 of 5

Ilogic Rule if flat pattern exists

leonque
Enthusiast
Enthusiast

Hi, friends from the forum.

Nowadays I´m using the following piece of code to obtain a rough approx amount of sheet metal needed to produce a given piece. Then that amount in sqm in written to a custom iprop.

iProperties.Value("Custom", "G_M2") = (Strings.FormatNumber((Round(SheetMetal.FlatExtentsLength)*((SheetMetal.FlatExtentsWidth))),0,,,0))/1000000

What I want to do next is to place it in a custom sheet metal template for pieces designed from scratch, but the problem with this method is that the above instruction returns error until the flat pattern is developed.

 

A) Help I need is for a conditional behaviour of the code that avoid the fail message:

1) Before obtaining the calculation, check If flat pattern is developed.

2) if it does no, then Custom iproperty = "0"

3) if it does exist, write the resultant calc from the above code.  

 

Else

 

B) A message box to be triggered before file is closed , that in case of exiting before flat pattern is developed warns about the fact that no area will be calculated without it.   

 

 

Thanks for your patience. 

 

 

0 Likes
Accepted solutions (1)
1,979 Views
4 Replies
Replies (4)
Message 2 of 5

JhoelForshav
Mentor
Mentor

@leonque 

Are you looking for something like this? 🙂

 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If oDef.HasFlatPattern
	iProperties.Value("Custom", "G_M2") = (Strings.FormatNumber((Round(SheetMetal.FlatExtentsLength) * ((SheetMetal.FlatExtentsWidth))), 0, , , 0)) / 1000000
Else
	iProperties.Value("Custom", "G_M2") = "0"
	MessageBox.Show("No flat pattern exists!", "Flat pattern warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
0 Likes
Message 3 of 5

leonque
Enthusiast
Enthusiast

Thanks a lot @JhoelForshav 

It works great.

Since the rule has a singular behaviour at the closing of the file it would be great if message form includes a Cancel button, so the user could revert the file exiting and finally make up his mind to develop the flat pattern. This way message works also as a checking factor for the process.

 

Great job JhoelForshav

 

 

 

 

0 Likes
Message 4 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

@leonque 

Are you triggering your rule on "Close document"?

I don't think that would be a good idea to have a rule that changes something in the document to trigger on close.

I'd suggest triggering on before save instead. That way the changes gets saved and the warning is enough as it is.

 

If you simply want a cancel-button to exit the rule you can use this:

Dim oDoc As PartDocument = ThisDoc.Document
Dim oDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
If oDef.HasFlatPattern
	iProperties.Value("Custom", "G_M2") = (Strings.FormatNumber((Round(SheetMetal.FlatExtentsLength) * ((SheetMetal.FlatExtentsWidth))), 0, , , 0)) / 1000000
Else
	iProperties.Value("Custom", "G_M2") = "0"
	Dim oDialogResult As DialogResult = MessageBox.Show("No flat pattern exists!", "Flat pattern warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning)
	If oDialogResult = DialogResult.Cancel
		Return
	End If
End If

But I don't think its possible to abort the closing of the document with a rule triggered on "Document Close"

Message 5 of 5

leonque
Enthusiast
Enthusiast

Thanks @JhoelForshav 

I´ll follow your suggestion.

Triggering before saving works better.

Now you can cancel the form, return and create the flat pattern.

 

Great!

Thanks for your help again. 

 

 

0 Likes