Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
emanuel.c
782 Views, 9 Replies

flat pattern extents when part not fully created

I have this piece of code (part of a function which returns "getstock") to calculate the area of the flat patterns of sheet metal, with an additional kerf, the thickness dimension. It works well, however I need to add some error exits and I'm not sure what exactly should be done. The code is triggered on Save. Basically, if the sheet metal is not yet created and I wish to save the part for the sake of the sketch it will trigger errors because there are no flat pattern extents. I could let the error be and keep on, but sometimes I may create sketches on sheet metal to drive other parts in the model.

 

Do I need to go with searching to see if those parameters (flat pattern extends) exist? I tried the If IsNot but that doesn't seem to work. What's the way to do it? Thank you much!

 

Dim smlength = SheetMetal.FlatExtentsLength 'sheet metal flat pattern length
	Dim smwidth = SheetMetal.FlatExtentsWidth 'sheet metal flat pattern width
	Dim AreaPronest As Double = (smlength + Parameter("Thickness")) * (smwidth + Parameter("Thickness")) / 144
	Dim oSMthk As Double = Parameter("Thickness")
	If Parameter("Thickness") >= 0.1875 Then
		getstock ="Plate, " & Format(oSMthk, "0.000") & " thk x " & Format(AreaPronest, "0.00") & " ft^2"
	Else
		getstock ="Sheet Metal, " & Format(oSMthk, "0.000") & " thk x " & Format(AreaPronest, "0.00") & " ft^2"
	End If