iLogic - Check SheetMetal flat pattern max size

iLogic - Check SheetMetal flat pattern max size

Ezekiel12
Collaborator Collaborator
1,400 Views
3 Replies
Message 1 of 4

iLogic - Check SheetMetal flat pattern max size

Ezekiel12
Collaborator
Collaborator

Hello Autodeskers,

I got problem with my iLogic rule. This rule is in my template (attached) and it should check Sheet metal changes and if Flat pattern of this sheet metal is bigger than size that I will enter on the creation, then message should PopUp. But it will also color my part to Red > Even when the Inventor color says Default, not red. So where do I have mistake?

 

Thx

 

CODE:

InventorVb.DocumentUpdate() 

iProperties.Value("Custom","X") = MaxOfMany(SheetMetal.FlatExtentsLength, SheetMetal.FlatExtentsWidth)
iProperties.Value("Custom","Y") = MinOfMany(SheetMetal.FlatExtentsLength, SheetMetal.FlatExtentsWidth)

If iProperties.Value("Custom","X") > iProperties.Value("Custom","MEZ_X") Or iProperties.Value("Custom","Y") > iProperties.Value("Custom","MEZ_Y") Then
	MessageBox.Show("Sheet metal is too big!" & vbLf & "Max dimensions are: " & iProperties.Value("Custom","MEZ_X") & " x " & iProperties.Value("Custom","MEZ_Y") & vbLf & "Your dimensions of flat pattern are: " & iProperties.Value("Custom","X") & " x " & iProperties.Value("Custom","Y"), "ERROR!",MessageBoxButtons.OK,MessageBoxIcon.Error)
Else
	MessageBox.Show("It's OK Your flat pattern dimensions are: " & iProperties.Value("Custom","X") & " x " & iProperties.Value("Custom","Y"), "OK")
End If







0 Likes
Accepted solutions (2)
1,401 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi Ezekiel12 ,

 

I don't have your version of Inventor on this machine, so I couldn't open your file. But I've attached a simple example file that checks the size of the sheet metal part against preset max values, and blinks or turns the part Red if the dimension is over set depending upon the feature that is set.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

EESignature

0 Likes
Message 3 of 4

Ezekiel12
Collaborator
Collaborator

Hi Curtis,

I tried your ipt as a tempalte for totally blank part and it works... there is nos ame bug as mine. Great 🙂 As I looking on your code I don't have idea where I was wrong but thx a lot. 🙂 

0 Likes
Message 4 of 4

Ezekiel12
Collaborator
Collaborator
Accepted solution

Hi Curtis,

thx one more time. And I hope you don't mind, I edited the code a little bit. No it suites more to us 🙂

 

Rule one (run at file creation):

 

oMyParameter=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters

nastX= InputBox("Set MAX dimension X", "Set MAX size", "")
nastY= InputBox("Set MAX dimension Y", "Set MAX size", "")

Try
Parameter("MAX_X") = nastX
Catch
oParameter=oMyParameter.AddByExpression("MAX_X", nastX, UnitsTypeEnum.kMillimeterLengthUnits)
End Try

RuleParametersOutput()
InventorVb.DocumentUpdate()

Try
Parameter("MAX_Y") = nastY
Catch
oParameter=oMyParameter.AddByExpression("MAX_Y", nastY, UnitsTypeEnum.kMillimeterLengthUnits)
End Try

RuleParametersOutput()
InventorVb.DocumentUpdate()

Try
Parameter("COLOR_SAVE") = Parameter("COLOR_SAVE")
Catch
oParameter=oMyParameter.AddByValue("COLOR_SAVE", "", UnitsTypeEnum.kTextUnits)
End Try

 

 

 

Rule two (run at Geometry change):

InventorVb.DocumentUpdate()

x = MaxOfMany(SheetMetal.FlatExtentsLength, SheetMetal.FlatExtentsWidth)
y = MinOfMany(SheetMetal.FlatExtentsLength, SheetMetal.FlatExtentsWidth)

maxX = MaxOfMany(Parameter("MAX_X"), Parameter("MAX_Y"))
maxY = MinOfMany(Parameter("MAX_X"), Parameter("MAX_Y"))

If iProperties.PartColor<>"Red" AndAlso iProperties.PartColor<>"Červená" Then 'English and Czech name of color
Parameter("COLOR_SAVE") = iProperties.PartColor
End If

If x > maxX Or y > maxY Then
iProperties.PartColor = "Red"
MessageBox.Show("Your dimensions are too large." & vbLf & "Max dimensions are:" & Parameter("MAX_X") & "x" & Parameter("MAX_Y") & vbLf & "Your dimensions are:" & Ceil(x) & "x" & Ceil(y), "ERROR!",MessageBoxButtons.OK,MessageBoxIcon.Error)
ThisApplication.ActiveView.Update()
Else
iProperties.PartColor = Parameter("COLOR_SAVE") 
ThisApplication.ActiveView.Update()
End If

So now it will at first ask what MAX diemsnions you want to check. Next change is that it will remember what color you had and save it so it will overwrite the Red color with your color you had before. 

And last change is that now it will check dimensions in both direction. (With your code I had a problem that if I had dimensions 1500x900 and MAX dimensions 1000x2000 then it thought that I can't fit it. But I can when I turn it - so I added it in code. 

 

 

Have a nice day!

 

 

 

0 Likes