Option Explicit On 'CONSTANTS - To be adjusted per implementation ''Default is ",", but can be overrided using the GSP. '''Semi-colon, ";", should be used as many regions use a comma as a decimal separator. Const OptionWizardValueDelimiter As String = ";" ''Rounding factor for dimensions ''Imperial is typically 1/16 or 0.0625 in ''Metric is typically 0.1 mm Const SYSTEM_MEASUREMENT_TYPE As Integer = 1 '1 = Imperial, 2 = Metric Const IMPERIAL_MULTIPLE As Single = 0.0625 Const METRIC_DECIMAL_PLACES As Integer = 1 Const MAX_EDGES As Integer = 8 Const DELIM As String = ";" Const DEFAULT_SIGHTLINE As Single = 0.125 'inches 'or 3 mm 'End CONSTANTS Function AttributeValue() As Variant Dim retval As Variant 'ENTER YOUR CALCULATION HERE!! 'VARIABLES Dim numSides As Integer Dim numSidesDXF As Integer Dim shapeNumberKey As String Dim shapeNumberOptionCode As String Dim shapeParameters As String Dim cuttingMethod As String Dim cutAsBlock As Boolean Dim ordWidth As Single Dim ordHeight As Single ''SHAPE Dim WF As Variant Dim HF As Variant Dim W As Variant Dim W1 As Variant Dim W2 As Variant Dim W3 As Variant Dim W4 As Variant Dim H As Variant Dim H1 As Variant Dim H2 As Variant Dim H3 As Variant Dim H4 As Variant Dim R As Variant Dim R1 As Variant Dim R2 As Variant Dim R3 As Variant Dim R4 As Variant Dim D As Variant Dim A As Variant Dim i As Long Dim strLeft As String Dim strRight As String Dim shapeParameter As String Dim shapeParameterValue As String Dim shpParam1 As ShapeParam1 Dim shpData1 As ShapeData1 Dim isEdgeCurved(MAX_EDGES) As Boolean Dim edgeLength(MAX_EDGES) As Double Dim dxfFileName As String Dim edge As Integer Dim edgeLengths As String Dim totalEdgeLength As Single Dim curvedEdges As String Dim straightEdges As String ''NOTCH Dim isDoubleNotch As Boolean Dim isTop As Boolean Dim isBottom As Boolean Dim isLeft As Boolean Dim isRight As Boolean Dim notchH As String Dim notchW As String Dim notchR As String Dim notchH1 As String Dim notchW1 As String Dim notchR1 As String Dim OH As Single Dim OW As Single Dim aW As Single Dim aWO As Single Dim aWBreak As Single Dim aR As Single Dim aH As Single Dim aHO As Single Dim aHBreak As Single Dim bW As Single Dim bWO As Single Dim bWBreak As Single Dim bR As Single Dim bH As Single Dim bHO As Single Dim bHBreak As Single 'OFFSET Dim offsetValue As String ''AREA Dim lites As Integer Dim lite As Integer Dim offsetData As String Dim offsetEdge As String Dim offsetEdgeValue As String Dim shpArea As Shape Dim area As Single ''SIGHTLINE Dim shpSightline1 As Shape Dim shpSightline2 As Shape Dim sightlineFullWidth As Single Dim sightlineFullHeight As Single Dim sightlinePerimeter As Single Dim sightlineEdgeLengths As String Dim sightlineQuestion As String Dim sightlineByEdgeQuestion As String Dim strSightline As String Dim sightline As String Dim spacerQuestion As String Dim spacer As String Dim spacerProfile As Single Dim adjustment As Double ''Temporary Variables Dim tmpStr As String Dim tmpSng As Single 'End VARIABLES 'INITIALIZE ''Clear attributes used in memory Attributes("SP-ID").Value = "" ''Variable init numSides = 4 shapeNumberKey = GroupKey("SHAPE NUMBER") cuttingMethod = "" If CustomExists("CuttingMethod") Then cuttingMethod = CustomValue("CuttingMethod") End If cutAsBlock = OptionExists("CUTBLK") ordWidth = Attributes("ORDW").Value ordHeight = Attributes("ORDH").Value lites = IIf(OptionExists("TRIPLE", "IG TYPE"), 3, IIf(OptionExists("DOUBLE", "IG TYPE"), 2, 1)) If shapeNumberKey <> "" Then 'Call the shape library; Checks the parameter for a value e.g. "W=" tmpStr = OptionValue(shapeNumberKey, "SHAPE NUMBER") If Right(tmpStr, 1) <> "=" Then shapeParameters = tmpStr 'e.g., "W=22;H=30;W1=12.125" or "W=22;H=30;W1=12,125" End If End If For i = 1 To MAX_EDGES isEdgeCurved(i) = False edgeLength(i) = 0 Next 'End INITIALIZE 'SHAPE If shapeNumberKey <> "" Then shapeNumberKey = LEFT(shapeNumberKey, 3) 'e.g., "001", "002" shapeNumberOptionCode = "SH" & shapeNumberKey 'e.g., "SH001", "SH002" 'Checks for parameters / rules and determines which shape to use in Opti If cuttingMethod = "BLOCK" Or cutAsBlock Then Attributes("SP-ID").value = "SH998" ElseIf cuttingMethod = "DXF" Then Attributes("SP-ID").value = "SH997" ElseIf CustomExists("Shape Manipulated") And Not cutAsBlock Then Attributes("SP-ID").value = "SH997" ElseIf cuttingMethod = "NONE" And shapeNumberOptionCode = "" Then Attributes("SP-ID").value = "SH000" Else Attributes("SP-ID").Value = shapeNumberOptionCode End If 'Initialize W and H values. Some shapes will override these values. ''Other shapes (those in the select statement) don't use the W and H values. Select Case CInt(shapeNumberKey) Case 60, 62 Case Else WF = ordWidth W = WF End Select Select Case CInt(shapeNumberKey) Case 20, 21, 22, 24, 51, 60 Case Else HF = ordHeight h = HF End Select 'Parse out values in the option string. Handles the string similar to using the "Split" function strRight = shapeParameters i = InStr(strRight, OptionWizardValueDelimiter) 'SHAPE - Parameter Parsing While i >= 0 And LenB(Trim(strRight)) > 0 If i > 0 Then strLeft = Trim(Left(strRight, i - 1)) strRight = Trim(Right(strRight, Len(strRight) - i)) Else 'last time through strLeft = strRight strRight = "" End If i = InStr(strLeft, "=") shapeParameter = Trim(LEFT(strLeft, i - 1)) shapeParameterValue = Trim(Right(strLeft, Len(strLeft) - i)) If IsNumeric(shapeParameterValue) = False Then shapeParameterValue = CStr(FracToDec(shapeParameterValue)) 'Sets variables using the option string Select Case shapeParameter Case "W" W = CSystem(CSng(shapeParameterValue)) Case "W1" W1 = CSystem(CSng(shapeParameterValue)) Case "W2" W2 = CSystem(CSng(shapeParameterValue)) Case "W3" W3 = CSystem(CSng(shapeParameterValue)) Case "W4" W4 = CSystem(CSng(shapeParameterValue)) Case "H" h = CSystem(CSng(shapeParameterValue)) Case "H1" H1 = CSystem(CSng(shapeParameterValue)) Case "H2" H2 = CSystem(CSng(shapeParameterValue)) Case "H3" H3 = CSystem(CSng(shapeParameterValue)) Case "H4" H4 = CSystem(CSng(shapeParameterValue)) Case "R" R = CSystem(CSng(shapeParameterValue)) Case "R1" R1 = CSystem(CSng(shapeParameterValue)) Case "R2" R2 = CSystem(CSng(shapeParameterValue)) Case "R3" R3 = CSystem(CSng(shapeParameterValue)) Case "R4" R4 = CSystem(CSng(shapeParameterValue)) Case "D" D = CSystem(CSng(shapeParameterValue)) Case "A" A = CSng(shapeParameterValue) End Select i = InStr(strRight, OptionWizardValueDelimiter) Wend 'End SHAPE - Parameter Parsing 'SHAPE - Shape Library shpParam1.ShapeNo = CInt(shapeNumberKey) shpParam1.W = W shpParam1.W1 = W1 shpParam1.W2 = W2 shpParam1.W3 = W3 shpParam1.W4 = W4 shpParam1.H = h shpParam1.H1 = H1 shpParam1.H2 = H2 shpParam1.H3 = H3 shpParam1.H4 = H4 shpParam1.R = R shpParam1.R1 = R1 shpParam1.R2 = R2 shpParam1.R3 = R3 shpParam1.R4 = R4 shpParam1.D = D shpParam1.A = A 'Checks to ensure that a value is set If Right(shapeParameters, 1) <> "=" Then shpData1 = GetShapeData(shpParam1) Me.SetEdgeParametersByShapeData1(shpData1, edgeLength, isEdgeCurved) WF = SystemRound(FullWidth()) HF = SystemRound(FullHeight()) Attributes("ORDW").value = WF Attributes("ORDH").value = HF numSides = shpData1.SideCount End If 'End SHAPE 'DXF ElseIf OptionExistsOR("DXF,DIG", "SHAPE") Then 'Check that there is no instruction to Cut as Block and set the ShapeID based on that, set the shapeID If cuttingMethod = "BLOCK" Or cutAsBlock Then Attributes("SP-ID").value = "SH998" Else Attributes("SP-ID").value = "SH997" End If dxfFileName = OptionValue(GroupCode("SHAPE"), "SHAPE") If dxfFileName <> "" Then shpData1 = GetShapeDataDXF(GetItemFilePath(dxfFileName)) Me.SetEdgeParametersByShapeData1(shpData1, edgeLength, isEdgeCurved) WF = Dec2Fract(FullWidth()) HF = Dec2Fract(FullHeight()) Attributes("ORDW").value = WF Attributes("ORDH").value = HF numSides = shpData1.SideCount numSidesDXF = numSides Attributes("NUMEDGESDXF").Value = numSidesDXF 'FV supports up to 8 sides, if over this amount we will cut as block If numSides > 8 Then numSides = 4 shpParam1 = GetShapeParam(GetShapeDXF(GetItemFilePath(dxfFileName))) End If 'End DXF 'NOTCH ElseIf OptionExistsOR("NOTCH,DBLNOTCH", "NOTCH") Then isDoubleNotch = OptionExists("DBLNOTCH", "NOTCH") numSides = IIf(isDoubleNotch, 8, 6) OH = OrderedHeight OW = OrderedWidth isTop = OptionExists("NTCHUP") isBottom = OptionExists("NTCHLO") isLeft = OptionExists("NTCHL") isRight = OptionExists("NTCHR") notchH = OptionValue("H") notchW = OptionValue("W") notchR = OptionValue("R") notchH1 = OptionValue("H1") notchW1 = OptionValue("W1") notchR1 = OptionValue("R1") WF = ordWidth HF = ordHeight 'First Notch Initial Values aW = 0.0 aWO = 0.0 aWBreak = 0.0 aR = 0.0 aH = 0.0 aHO = 0.0 aHBreak = 0.0 'Second Notch Initial Values bW = 0.0 bWO = 0.0 bWBreak = 0.0 bR = 0.0 bH = 0.0 bHO = 0.0 bHBreak = 0.0 'Begin parsing code, this will allow the system to measure the length of each edge if corner notch is used 'Checks first set of notch code/values If notchH = "" Or notchW = "" Then Exit Function Else 'Parse H and W aR = IIf(notchR = "", 0.0, FracToDec(notchR)) Me.ParseOOSDimension(notchH, aH, aHO) Me.ParseOOSDimension(notchW, aW, aWO) If Not isDoubleNotch Then If aH > 0 And aW > 0 Then 'Setting edges for Notch If isLeft Then If isBottom Then 'Lower Left edgeLength(1) = OW - aW edgeLength(2) = OH edgeLength(3) = OW edgeLength(4) = OH - aH edgeLength(5) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(6) = Sqr((aH + aHO)^2 + aWO^2) ElseIf isTop Then 'Upper Left edgeLength(1) = OW edgeLength(2) = OH edgeLength(3) = OW - aW edgeLength(4) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(5) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(6) = OH - aH End If ElseIf isRight Then If isBottom Then 'Lower Right edgeLength(1) = OW - aW edgeLength(2) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(3) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(4) = OH - aH edgeLength(5) = OW edgeLength(6) = OH ElseIf isTop Then 'Upper Right edgeLength(1) = OW edgeLength(2) = OH - aH edgeLength(3) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(4) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(5) = OW - aW edgeLength(6) = OH End If End If End If Else 'Double Notch bR = IIf(notchR1 = "", 0.0, FracToDec(notchR1)) Me.ParseOOSDimension(notchH1, bH, bHO) Me.ParseOOSDimension(notchW1, bW, bWO) If aH > 0 And aW > 0 And bH > 0 And bW > 0 Then If isLeft Then If isBottom Then 'Lower Left edgeLength(1) = OW - (aW + bW) edgeLength(2) = OH edgeLength(3) = OW edgeLength(4) = OH - (aH + bH) edgeLength(5) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(6) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(7) = Sqr((bW + bWO)^2 + bHO^2) edgeLength(8) = Sqr((bH + bHO)^2 + bWO^2) ElseIf isTop Then 'Upper Left edgeLength(1) = OW edgeLength(2) = OH edgeLength(3) = OW - (aW + bW) edgeLength(4) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(5) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(6) = Sqr((bH + bHO)^2 + bWO^2) edgeLength(7) = Sqr((bW + bWO)^2 + bHO^2) edgeLength(8) = OH-(aH + aWO + bH + bWO) End If ElseIf isRight Then If isBottom Then 'Lower Right edgeLength(1) = OW - (aW + bW) edgeLength(2) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(3) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(4) = Sqr((bH + bHO)^2 + bWO^2) edgeLength(5) = Sqr((bW + bWO)^2 + bHO^2) edgeLength(6) = OH - (aH + bH) edgeLength(7) = OW edgeLength(8) = OH ElseIf isTop Then 'Upper Right edgeLength(1) = OW edgeLength(2) = OH - (aH + bH) edgeLength(3) = Sqr((aW + aWO)^2 + aHO^2) edgeLength(4) = Sqr((aH + aHO)^2 + aWO^2) edgeLength(5) = Sqr((bW + bWO)^2 + bHO^2) edgeLength(6) = Sqr((bH + bHO)^2 + bWO^2) edgeLength(7) = OW - (aW + bW) edgeLength(8) = OH End If End If End If End If 'Rounds notch edge values found For edge = 1 To MAX_EDGES edgeLength(edge) = Round(edgeLength(edge), 2) Next End If 'Determines which shape number should be used for Opti Attributes("SP-ID").Value = "SH997" If cuttingMethod = "BLOCK" Then Attributes("SP-ID").value = "SH998" ElseIf cuttingMethod = "DXF" Then Attributes("SP-ID").value = "SH997" ElseIf CustomExists("CUT-SCORES-REQUIRED:MONO") Or CustomExists("CUT-SCORES-REQUIRED:L1") Then Attributes("SP-ID").value = "SH997" ElseIf cuttingMethod = "NONE" Or shapeNumberKey = "" Then Attributes("SP-ID").Value = "SH000" End If 'End NOTCH 'RECTANGLE Else WF = ordWidth HF = ordHeight W = ordWidth H = ordHeight edgeLength(1) = WF edgeLength(2) = HF edgeLength(3) = WF edgeLength(4) = HF numSides = 4 ''Determines which shape number should be used for Opti If cuttingMethod = "BLOCK" Then Attributes("SP-ID").value = "SH998" ElseIf cuttingMethod = "DXF" Then Attributes("SP-ID").value = "SH997" ElseIf CustomExists("CUT-SCORES-REQUIRED:MONO") Or CustomExists("CUT-SCORES-REQUIRED:L1") Then Attributes("SP-ID").value = "SH997" ElseIf cuttingMethod = "NONE" Or shapeNumberKey = "" Then Attributes("SP-ID").value = "SH000" End If ''If different cutting rules apply (option structure), we will override SP-ID If cutAsBlock Then Attributes("SP-ID").value = "SH998" ElseIf OptionExists("CUTSHP") Then Attributes("SP-ID").value = "SH997" End If ''May be able to remove this portion of code, take a look in to "ArchTop" value If CustomExists("ArchTop") Then If CustomValue("ArchTop") = "1" Then If OptionExists("EWINCL") Then Attributes("SP-ID").value = "SH997" Else Attributes("SP-ID").value = "SH999" End If End If End If ''Setup Shape parameters and get shape shpParam1.ShapeNo = 0 shpParam1.W = W shpParam1.W1 = 0 shpParam1.W2 = 0 shpParam1.W3 = 0 shpParam1.W4 = 0 shpParam1.H = H shpParam1.H1 = 0 shpParam1.H2 = 0 shpParam1.H3 = 0 shpParam1.H4 = 0 shpParam1.R = 0 shpParam1.R1 = 0 shpParam1.R2 = 0 shpParam1.R3 = 0 shpParam1.R4 = 0 shpParam1.D = 0 shpParam1.A = 0 End If 'End RECTANGLE 'OFFSET For lite = 1 To lites offsetData = "" If GroupExists("LITE " & lite & " OFFSET") Then For edge = 1 To numSides 'e.g., OL1E1 = Lite 1 Edge 1; OL2E5 = Lite 2 Edge 5; etc offsetValue = OptionValue("OL" & lite & "E" & edge, "LITE " & lite & " OFFSET") If offsetValue <> "" Then offsetData &= "E" & edge & "=" & offsetValue & DELIM 'e.g., E1=5; End If Next End If If Attributes.Exists("OFFSET" & lite) Then Attributes("OFFSET" & lite).Value = offsetData End If Next 'End OFFSET 'AREA ''These shapes will be used later in the SIGHTLINE area, but we can do the offset adjustments here as we are already looping through it all Set shpSightline1 = GetShape(shpParam1) Set shpSightline2 = GetShape(shpParam1) For lite = 1 To lites offsetData = "" If Attributes.Exists("OFFSET" & lite) Then offsetData = Attributes("OFFSET" & lite).Value End If Set shpArea = GetShape(shpParam1) strRight = offsetData i = InStr(strRight, DELIM) While i >= 0 And LenB(Trim(strRight)) > 0 If i > 0 Then strLeft = Trim(Left(strRight, i - 1)) strRight = Trim(Right(strRight, Len(strRight) - i)) Else 'last time through strLeft = strRight strRight = "" End If i = InStr(strLeft, "=") offsetEdge = Trim(Left(strLeft, i - 1)) offsetEdgeValue = Trim(Right(strLeft, Len(strLeft) - i)) If IsNumeric(offsetEdgeValue) = False Then offsetEdgeValue = CStr(FracToDec(offsetEdgeValue)) offsetEdge = Right(offsetEdge, 2) If offsetEdge Like "E#" And Len(offsetEdge) = 2 Then offsetEdge = Right(offsetEdge, 1) shpArea.AdjustShapeSide(CInt(offsetEdge), - CSystem(CSng(offsetEdgeValue)), 0) End If i = InStr(strRight, DELIM) Wend area = shpArea.ShapeArea / IIf(SYSTEM_MEASUREMENT_TYPE = 1, 144, 1000000) If Attributes.Exists("L" & lite & "-AREA") Then Attributes("L" & lite & "-AREA").Value = area End If ''Additional sightline adjustments for the next lite offsetData = GetSightlineOffsetData(lite) strRight = offsetData i = InStr(strRight, DELIM) While i >= 0 And LenB(Trim(strRight)) > 0 If i > 0 Then strLeft = Trim(Left(strRight, i - 1)) strRight = Trim(Right(strRight, Len(strRight) - i)) Else 'last time through strLeft = strRight strRight = "" End If i = InStr(strLeft, "=") offsetEdge = Trim(Left(strLeft, i - 1)) offsetEdgeValue = Trim(Right(strLeft, Len(strLeft) - i)) If IsNumeric(offsetEdgeValue) = False Then offsetEdgeValue = CStr(FracToDec(offsetEdgeValue)) offsetEdge = Right(offsetEdge, 2) If offsetEdge Like "E#" And Len(offsetEdge) = 2 Then offsetEdge = Right(offsetEdge, 1) Select Case lite Case 1 shpSightline1.AdjustShapeSide(CInt(offsetEdge), - CSystem(CSng(offsetEdgeValue)), 0) Case 2 shpSightline2.AdjustShapeSide(CInt(offsetEdge), - CSystem(CSng(offsetEdgeValue)), 0) End Select End If i = InStr(strRight, DELIM) Wend Next 'End AREA 'SIGHTLINE If lites > 1 Then For lite = 1 To lites - 1 spacerQuestion = "SPACER " & lite spacer = GroupCode(spacerQuestion) spacerProfile = 0 'TableLookup("Spacers", "PROFILE", spacer & "-" & OptionValue(spacer, spacerQuestion)) sightlineQuestion = IIf(lite = 1, "SIGHTLINE", "SIGHTLINE 2") sightlineByEdgeQuestion = IIf(lite = 1, "SIGHTLINE BY EDGE", "SIGHTLINE 2 BY EDGE") sightline = "" strSightline = OptionValue("SLALL", sightlineQuestion) If strSightline <> "" Then If Not IsNumeric(strSightline) Then strSightline = CStr(FracToDec(strSightline)) End If sightline = strSightline For edge = 1 To shpSightline1.NumberOfSides adjustment = -CSng(strSightline) - spacerProfile Me.SightlineAdjustShapeSide(shpSightline1, shpSightline2, lite, edge, adjustment) Next ElseIf OptionExists("SLEDGE", sightlineQuestion) Then For edge = 1 To shpSightline1.NumberOfSides strSightline = OptionValue("SL" & edge & "CUST", sightlineByEdgeQuestion) If strSightline <> "" Then If Not IsNumeric(strSightline) Then strSightline = CStr(FracToDec(strSightline)) End If sightline &= "E" & edge & "=" & strSightline & DELIM adjustment = -CSng(strSightline) - spacerProfile Me.SightlineAdjustShapeSide(shpSightline1, shpSightline2, lite, edge, adjustment) Else sightline &= "E" & edge & "=" & CStr(DEFAULT_SIGHTLINE) & DELIM adjustment = -DEFAULT_SIGHTLINE - spacerProfile Me.SightlineAdjustShapeSide(shpSightline1, shpSightline2, lite, edge, adjustment) End If Next Else ' Standard/Default Sightline sightline = CStr(DEFAULT_SIGHTLINE) For edge = 1 To shpSightline1.NumberOfSides adjustment = -DEFAULT_SIGHTLINE - spacerProfile Me.SightlineAdjustShapeSide(shpSightline1, shpSightline2, lite, edge, adjustment) Next End If If Attributes.Exists("S-LINE" & lite) Then Attributes("S-LINE" & lite).Value = sightline End If If Attributes.Exists("SL-PERIM" & lite) Then Me.CalculateSightlineLengths(IIf(lite = 1, shpSightline1, shpSightline2), sightlinePerimeter, sightlineEdgeLengths) Attributes("SL-PERIM" & lite).Value = sightlinePerimeter Attributes("SL-PERIM" & lite & "-EL").Value = sightlineEdgeLengths End If If Attributes.Exists("SL" & lite & "-SHPSTR") Then sightline = "" Select Case lite Case 1 shpParam1 = GetShapeParam(shpSightline1) sightlineFullWidth = shpSightline1.WidthFull sightlineFullHeight = shpSightline1.HeightFull Case 2 shpParam1 = GetShapeParam(shpSightline2) sightlineFullWidth = shpSightline2.WidthFull sightlineFullHeight = shpSightline2.HeightFull End Select Me.BuildShapeString(sightline, "WF", sightlineFullWidth) Me.BuildShapeString(sightline, "W", shpParam1.W) Me.BuildShapeString(sightline, "W1", shpParam1.W1) Me.BuildShapeString(sightline, "W2", shpParam1.W2) Me.BuildShapeString(sightline, "W3", shpParam1.W3) Me.BuildShapeString(sightline, "W4", shpParam1.W4) Me.BuildShapeString(sightline, "HF", sightlineFullHeight) Me.BuildShapeString(sightline, "H", shpParam1.H) Me.BuildShapeString(sightline, "H1", shpParam1.H1) Me.BuildShapeString(sightline, "H2", shpParam1.H2) Me.BuildShapeString(sightline, "H3", shpParam1.H3) Me.BuildShapeString(sightline, "H4", shpParam1.H4) Me.BuildShapeString(sightline, "R", shpParam1.R) Me.BuildShapeString(sightline, "R1", shpParam1.R1) Me.BuildShapeString(sightline, "R2", shpParam1.R2) Me.BuildShapeString(sightline, "R3", shpParam1.R3) Me.BuildShapeString(sightline, "R4", shpParam1.R4) Me.BuildShapeString(sightline, "D", shpParam1.D) Me.BuildShapeString(sightline, "A", shpParam1.A) Attributes("SL" & lite & "-SHPSTR").Value = sightline End If Next End If 'End SIGHTLINE 'RETURN retval = "" 'May be able to remove this portion with other logic handling this, check where NumEdges is used If CustomExists("NumEdges") Then If CSng(CustomValue("NumEdges")) > 8 Then numSides = 8 Else numSides = CSng(CustomValue("NumEdges")) End If End If ''Start building up the return value with the shape parameter values. Me.BuildShapeString(retval, "WF", WF) Me.BuildShapeString(retval, "W", W) Me.BuildShapeString(retval, "W1", W1) Me.BuildShapeString(retval, "W2", W2) Me.BuildShapeString(retval, "W3", W3) Me.BuildShapeString(retval, "W4", W4) Me.BuildShapeString(retval, "HF", HF) Me.BuildShapeString(retval, "H", H) Me.BuildShapeString(retval, "H1", H1) Me.BuildShapeString(retval, "H2", H2) Me.BuildShapeString(retval, "H3", H3) Me.BuildShapeString(retval, "H4", H4) Me.BuildShapeString(retval, "R", R) Me.BuildShapeString(retval, "R1", R1) Me.BuildShapeString(retval, "R2", R2) Me.BuildShapeString(retval, "R3", R3) Me.BuildShapeString(retval, "R4", R4) Me.BuildShapeString(retval, "D", D) Me.BuildShapeString(retval, "A", A) ''Add number of edges Me.BuildShapeString(retval, "NUMEDGE", numSides) 'Strictly for showers If Attributes.Exists("SD-ID") Then If Attributes("SD-ID").Value <> "" Then Me.SetEdgeParametersFromCAD(edgeLength, isEdgeCurved) End If End If ''Save Edge Parameters to Attributes edgeLengths = "" totalEdgeLength = 0 curvedEdges = "" straightEdges = "" For edge = 1 To MAX_EDGES If edgeLength(edge) Then edgeLengths &= "E" & edge & "=" & edgeLength(edge) & DELIM totalEdgeLength += edgeLength(edge) If isEdgeCurved(edge) Then curvedEdges &= "E" & edge & DELIM Else straightEdges &= "E" & edge & DELIM End If End If Next ''Handles DXFs over 8 sides, uses full height / width for edgework values; charges for straight edgework '''NOTE: Can support CURVED edgework pricing; just need to assign "E1;E2;E3;E4;" string to "CURVEDEDGES" attribute instead If numSidesDXF > 8 Then edgeLengths = "" totalEdgeLength = 0 curvedEdges = "" straightEdges = "" For edge = 1 To 4 tmpSng = IIf(edge = 1 Or edge = 3, WF, HF) If edgeLength(edge) Then edgeLengths &= "E" & edge & "=" & tmpSng & DELIM totalEdgeLength += tmpSng straightEdges &= "E" & edge & DELIM Next End If Attributes("EDGELENGTH").Value = edgeLengths Attributes("PERIM").Value = totalEdgeLength Attributes("CURVEDEDGES").Value = curvedEdges Attributes("STRAIGHTEDGES").Value = straightEdges Attributes("NUMEDGES").Value = numSides 'End RETURN 'DO NOT MODIFY CODE BELOW THIS LINE AttributeValue = retval End Function Private Function ParseDimension(ByVal dimStr As Variant) As Single ParseDimension = 0 If dimStr <> "" Then If IsNumeric(dimStr) Then ParseDimension = dimStr Else ParseDimension = FracToDec(dimStr) End If End If End Function Sub ParseOOSDimension(ByVal inputString, ByRef length, ByRef oos) Dim pairLengthOOS() As String If InStr(inputString, "+") > 0 Then pairLengthOOS = Split(inputString, "+") length = CSng(FracToDec(pairLengthOOS(0))) oos = CSng(FracToDec(pairLengthOOS(1))) ElseIf InStr(inputString, "-") > 0 Then pairLengthOOS = Split(inputString, "-") length = CSng(FracToDec(pairLengthOOS(0))) oos = -1 * CSng(FracToDec(pairLengthOOS(1))) Else length = CSng(FracToDec(inputString)) oos = 0.0 End If End Sub Function Dec2Fract(X As Single) As String ' Returns a string of a number rounded to a whole and fraction in 16ths, 32nds, etc. ' Handles number > 1 and less than 0 ' Use as follows: ' Label1.Caption = Dec2Fract(Val(Text1.Text)) ' or Label1.Caption = Dec2Fract(Val(Label1.Caption) Dim F As String Dim Y As Single Dim Num As Integer Dim Den As Integer Den = 16 'Denominator: can be set to 8, 16, 32, 64 etc If X = 0 Then Dec2Fract = "0" Exit Function Else Y = Abs(X) If Y > 1 Then Y = Y - Int(Y) ' get fractional part Num = CInt(Den * Y) If Num = Den Then F = "1" ElseIf Num = 0 Then If Abs(X) < 1 Then F = "0" Else F = "" Else Do Until Num Mod 2 <> 0 Num = Num / 2 Den = Den / 2 Loop F = LTrim$(Str$(Num)) + "/" + LTrim$(Str$(Den)) End If If Abs(X) > 1 Then If F <> "1" Then F = Trim$(Str$(Fix(X))) + " " + F Else F = Trim$(Str$(CInt(X))) End If End If If X < 0 And X > -1 Then F = "-" + F Dec2Fract = CStr(FracToDec(F)) End If End Function Sub SetEdgeParametersByShapeData1(ByRef shpData1 As ShapeData1, ByRef edgeLength() As Double, ByRef isEdgeCurved() As Boolean) Dim edgeCount As Integer Dim edge As Integer edgeCount = SideCount() For edge = 1 To MAX_EDGES If edgeCount >= edge Then edgeLength(edge) = SystemRound(SideLength(edge)) isEdgeCurved(edge) = IsCurved(edge) End If Next End Sub Sub SetEdgeParametersFromCAD(ByRef edgeLength() As Double, ByRef isEdgeCurved() As Boolean) Dim edge As Integer For edge = 1 To MAX_EDGES If CustomExists("EL" & edge) Then edgeLength(edge) = CustomValue("EL" & edge) End If If CustomExists("EC" & edge) Then isEdgeCurved(edge) = True End If Next End Sub Function GetSightlineOffsetData(ByVal lite As Integer) As String Dim offsetDataA As String Dim offsetDataB As String Dim offset As String Dim offsetSplit() As String Dim offsetDataAValues(MAX_EDGES) As Single Dim offsetDataBValues(MAX_EDGES) As Single Dim edge As Integer Dim maxOffset As Single If Attributes.Exists("OFFSET" & lite) Then offsetDataA = Attributes("OFFSET" & lite).Value End If If Attributes.Exists("OFFSET" & CStr(lite + 1)) Then offsetDataB = Attributes("OFFSET" & CStr(lite + 1)).Value End If For Each offset In split(offsetDataA, DELIM) 'E2=10;E3=5; If offset <> "" Then offsetSplit = split(offset, "=") offsetSplit(0) = Replace(offsetSplit(0), "E", "") offsetDataAValues(CInt(offsetSplit(0))) = CSng(offsetSplit(1)) End If Next For Each offset In split(offsetDataB, DELIM) If offset <> "" Then offsetSplit = split(offset, "=") offsetSplit(0) = Replace(offsetSplit(0), "E", "") offsetDataBValues(CInt(offsetSplit(0))) = CSng(offsetSplit(1)) End If Next GetSightlineOffsetData = "" For edge = 1 To MAX_EDGES maxOffset = MathMax(offsetDataAValues(edge), offsetDataBValues(edge)) If maxOffset > 0 Then GetSightlineOffsetData &= "E" & edge & "=" & maxOffset & DELIM End If Next End Function Sub SightlineAdjustShapeSide(ByRef shp1 As Shape, ByRef shp2 As Shape, ByVal lite As Integer, ByVal edge As Integer, ByVal adjustment As Double) Select Case lite Case 1 shp1.AdjustShapeSide(edge, adjustment, adjustment) Case 2 shp2.AdjustShapeSide(edge, adjustment, adjustment) End Select End Sub Sub CalculateSightlineLengths(ByVal shp As Shape, ByRef sightlinePerimeter As Single, ByRef sightlineEdgeLengths As String) Dim edge As Integer sightlinePerimeter = 0 sightlineEdgeLengths = "" For edge = 1 To shp.NumberOfSides sightlinePerimeter += shp.GetShapeSide(edge).Length sightlineEdgeLengths &= "E" & edge & "=" & Round(shp.GetShapeSide(edge).Length, 2) & DELIM Next End Sub Function SystemRound(ByVal measurement As Double, Optional ByVal precise As Boolean = False) As Double Select Case SYSTEM_MEASUREMENT_TYPE Case 1 'Imperial SystemRound = MRound(measurement, IMPERIAL_MULTIPLE) Case 2 'Metric SystemRound = Round(measurement, METRIC_DECIMAL_PLACES) End Select End Function Sub BuildShapeString(ByRef shpStr As String, ByVal parameter As String, ByVal parameterValue As Variant) If Not IsEmpty(parameterValue) Then shpStr &= parameter & "=" & parameterValue & DELIM End If End Sub