Plate Thickness, width and Length automatic creation using ilogic

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I found this great Ilogic here that helps me to get the thickness width and length of a plate and works great.
The problem I am having is that if the plate is slanted (looking from the top) the thickness of the plate is not showing correctly because it is skew. What is the best way to fix this? I'm guessing rotating the UCS but that does not do it. SO I have been sketching on the face of the plate and projecting geometries to get the thickness, width and length linking that to the parameters. I then add the word "SPECIAL PART" under authority iprop, so my illogic doesn't override it. Its my work around it but if there is an easier way of doing it then I would like to know.
Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 112746 StartFragment: 314 EndFragment: 112714 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet
'MEASURES OVERALL X, Y, AND Z DIMENSIONS X_MEASURE = Measure.ExtentsLength Y_MEASURE = Measure.ExtentsWidth Z_MEASURE = Measure.ExtentsHeight 'SORTS MEASURED DIMENSIONS TO FIND THE LENGTH, WIDTH AND HEIGHT OF PART xdim = MaxOfMany(X_MEASURE,Y_MEASURE,Z_MEASURE) ydim = MinOfMany(X_MEASURE,Y_MEASURE,Z_MEASURE) zdim = (X_MEASURE + Y_MEASURE + Z_MEASURE) - xdim - ydim 'ROUNDS DIMENSIONS TO NEAREST 1/16" dimx = Round(xdim*16 ul)*.0625 dimy = Round(ydim*128 ul)*.0078125 dimz = Round(zdim*16 ul)*.0625 InventorVb.DocumentUpdate() iLogicVb.UpdateWhenDone = True If iProperties.Value("Project", "Authority") = "SPECIAL PART" Then Try oTest = Parameter("B_T") Catch End Try iProperties.Value("Custom", "B_T") = Parameter("B_T") dmy = Round(Parameter("B_T")*16 ul)*.0625 Select Case dmy Case 0.0625 '16GA oVNR = "445-0016" Case 0.078125 '14GA oVNR = "445-0014" Case 0.109375 '12GA oVNR = "445-0012" Case 0.125 '11GA oVNR = "445-0011" Case 0.1345 '10GA oVNR = "445-0010" Case 0.1875 oVNR = "445-0203" Case 0.25 oVNR = "445-0204" Case 0.3125 oVNR = "445-0205" Case 0.375 oVNR = "445-0206" Case 0.5 oVNR = "445-0208" Case 0.625 oVNR = "445-0210" Case 0.75 oVNR = "445-0212" Case 0.875 oVNR = "445-0214" Case 1 oVNR = "445-0216" Case 1.125 oVNR = "445-0218" Case 1.25 oVNR = "445-0220" Case 1.375 oVNR = "445-0222" Case 1.5 oVNR = "445-0224" Case 1.75 oVNR = "445-0228" Case 2 oVNR = "445-0232" Case 2.125 oVNR = "445-0234" Case 2.25 oVNR = "445-0236" Case 2.375 oVNR = "445-0238" Case 2.5 oVNR = "445-0240" Case 2.75 oVNR = "445-0244" Case 3 oVNR = "445-0248" Case 3.25 oVNR = "445-0252" Case Else oVNR = "445-????" End Select iProperties.Value("Project", "Vendor") = oVNR iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, <B_T>" Return End If 'ADDS A ZERO If DIMENSION DISPLAYS X.5'ADDS TWO ZEROS IF DIMENSION DISPLAYS X If (Round(dimx,0)+1)-dimx = .5 Then dmx = dimx & "" ElseIf (Round(dimx,0)+1)-dimx = 1 Then dmx = dimx & "" Else dmx = dimx End If If (Round(dimy,0)+1)-dimy = .5 Then dmy = dimy & "0" ElseIf (Round(dimy,0)+1)-dimy = 1 Then dmy = dimy & "" Else dmy = dimy End If If (Round(dimz,0)+1)-dimz = .5 Then dmz = dimz & "" ElseIf (Round(dimz,0)+1)-dimz = 1 Then dmz = dimz & "" Else dmz = dimz End If 'CREATES CUSTOM iPROPERTY FOR THE BOM iProperties.Value("Custom", "B_L") = dmx iProperties.Value("Custom", "B_W") = dmz iProperties.Value("Custom", "B_T") = dmy ' Set up parameters ' Get the active document. Assumes a part document is active. Dim partDoc As PartDocument partDoc = ThisDoc.Document 'partDoc = ThisApplication.ActiveDocument 'get filename Filename = ThisDoc.FileName(False) 'get the drawing number drawingnumber = Left(filename,8) 'get description name description = Mid(filename,10, 40) ' Get the UserParameters collection Dim userParams As UserParameters userParams = partDoc.ComponentDefinition.Parameters.UserParameters Try Parameter("B_L") = dmx Catch param = userParams.AddByExpression("B_L", dmx, UnitsTypeEnum.kInchLengthUnits) 'param = partDoc.ComponentDefinition.Parameters.Item("B_L") param.ExposedAsProperty = True param.CustomPropertyFormat.Units = "in" param.CustomPropertyFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision 'param.CustomPropertyFormat.ShowTrailingZeros = False param.CustomPropertyFormat.ShowUnitsString = False End Try Try Parameter("B_W") = dmz Catch param = userParams.AddByExpression("B_W", dmz, UnitsTypeEnum.kInchLengthUnits) 'param = partDoc.ComponentDefinition.Parameters.Item("B_W") param.ExposedAsProperty = True param.CustomPropertyFormat.Units = "in" param.CustomPropertyFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision 'param.CustomPropertyFormat.ShowTrailingZeros = False param.CustomPropertyFormat.ShowUnitsString = False End Try Try Parameter("B_T") = dmy Catch param = userParams.AddByExpression("B_T", dmy, UnitsTypeEnum.kInchLengthUnits) 'param = partDoc.ComponentDefinition.Parameters.Item("B_T") param.ExposedAsProperty = True param.CustomPropertyFormat.Units = "in" param.CustomPropertyFormat.Precision = Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision param.CustomPropertyFormat.ShowUnitsString = False End Try 'oB_TConverted = Parameter("B_T") oBT = RoundToFraction(dmy, 1/32, RoundingMethod.Round) fBT = oBT & """" 'select the case for B_T Select Case dmy Case 0.0625 '16GA oVNR = "445-0016" Case 0.078125 '14GA oVNR = "445-0014" Case 0.109375 '12GA oVNR = "445-0012" Case 0.125 '11GA oVNR = "445-0011" Case 0.1345 '10GA oVNR = "445-0010" Case 0.1875 oVNR = "445-0203" Case 0.25 oVNR = "445-0204" Case 0.3125 oVNR = "445-0205" Case 0.375 oVNR = "445-0206" Case .5 oVNR = "445-0208" Case 0.625 oVNR = "445-0210" Case 0.75 oVNR = "445-0212" Case 0.875 oVNR = "445-0214" Case 1 oVNR = "445-0216" Case 1.125 oVNR = "445-0218" Case 1.25 oVNR = "445-0220" Case 1.375 oVNR = "445-0222" Case 1.5 oVNR = "445-0224" Case 1.75 oVNR = "445-0228" Case 2 oVNR = "445-0232" Case 2.125 oVNR = "445-0234" Case 2.25 oVNR = "445-0236" Case 2.375 oVNR = "445-0238" Case 2.5 oVNR = "445-0240" Case 2.75 oVNR = "445-0244" Case 3 oVNR = "445-0248" Case 3.25 oVNR = "445-0252" Case Else oVNR = "445-????" End Select '] '[ set iproperties iProperties.Value("Project", "Vendor") = oVNR iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, <B_T>" iProperties.Value("Project", "Cost Center") = "=<B_W> x <B_L>" If iProperties.Material = "Aluminum 6061" Select Case dmy Case 0.375 oVNR = "449-5206" Case .5 oVNR = "449-5208" Case 0.625 oVNR = "449-5210" Case 0.75 oVNR = "449-5212" Case 0.875 oVNR = "449-5214" Case 1 oVNR = "449-5216" Case 1.125 oVNR = "449-5218" Case 1.25 oVNR = "449-5220" Case 1.375 oVNR = "449-5222" Case 1.5 oVNR = "449-5224" Case 1.75 oVNR = "449-5228" Case 2 oVNR = "449-5232" Case 2.125 oVNR = "449-5234" Case 2.25 oVNR = "449-5236" Case 2.375 oVNR = "449-5238" Case 2.5 oVNR = "449-5240" Case 2.75 oVNR = "449-5244" Case 3 oVNR = "449-5248" Case 3.25 oVNR = "449-5252" Case Else oVNR = "445-????" End Select iProperties.Value("Project", "Vendor") = oVNR iProperties.Value("Project", "WEB Link") = "=PLATE, ALUMINUM, <Thickness> THK, 6061T6" End If DNL = Mid(filename,9,4) 'check part if its single part Dim spart As String spart = Mid(filename,9,2) 'If filename .contains("-") Then If spart = "00" Then iProperties.Value("Project", "Stock Number") = iProperties.Value("Project", "Vendor") iProperties.Value("Project", "Description") = iProperties.Value("Project", "WEB Link") Else iProperties.Value("Project", "Stock Number") = drawingnumber End If If oVNR = "445-0014" Then iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, #14 GA" End If If oVNR = "445-0012" Then iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, #12 GA" End If If oVNR = "445-0011" Then iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, #11 GA" End If If oVNR = "445-0010" Then iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, #10 GA" End If If oVNR = "445-0016" Then iProperties.Value("Project", "WEB Link") = "=PL, MS, HR, #16 GA" End If odrawingname = ThisDoc.FileName(False) opartname = Mid(odrawingname, 5,8) iLogicVb.UpdateWhenDone = True ']