Plate Thickness, width and Length automatic creation using ilogic

Plate Thickness, width and Length automatic creation using ilogic

Anonymous
Not applicable
2,448 Views
5 Replies
Message 1 of 6

Plate Thickness, width and Length automatic creation using ilogic

Anonymous
Not applicable

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
']
0 Likes
2,449 Views
5 Replies
Replies (5)
Message 2 of 6

MechMachineMan
Advisor
Advisor

Not generally.

 

Oriented Bounding Box algorithms are generally pretty complex.

 

For a "2D" part with a thickness it might be easier, but there is a SLIM chance someone out there might have something developed for your needs. I would not count on it thought.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 6

dgreatice
Collaborator
Collaborator

Hi,

 

Maybe it look like this:

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 4 of 6

Anonymous
Not applicable

Thanks for the reply Justin. 

 

I wish it was that easy as moving that UCS and making that "bounding box" rotates as per the plane on UCS.  Another option is to have an option of rotating the derived sketch, say horizontal to a line in the sketch.  For now i'll just do it manually. 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Thanks dgreatice, but its not quite I'm looking for.. for regular plates I can get the x y z of that plate based on the illogic I posted..what gives me trouble is when that plate is rotate in an angle (say looking from the top its 45 degree) then that xyz of the original plane is no longer correct.  SO what I would do is sketch on the actual plate plane and project geometry and use those geometry as parameters.

 

Works okay for now just extra work.

 

THanks,

Joel

0 Likes
Message 6 of 6

MechMachineMan
Advisor
Advisor

Another idea I have that would probably work, because of the fact that Measure and RangeBox directions are ALWAYS square to the origin planes.

 

Write a macro that does the following:

 

Step 1: Prompts user to select plane "parallel" to thickness of material (ie; the top or bottom of the plate)

Step 2: Prompts user to select perpendicular plane to plane 1 that they wish to have aligned (ie; for the bottom/reference line in the drawing view)

Step 3: Use these planes and do the geometric calculations required to move the bodies to align them with the part origin planes

Step 4: Move the body as per step 3.

Step 5: Use the default measure/rangebox commands to grab the dimensions

Step 6: Prompt user to verify the measured dimensions.

Step 7: ???

Step 8: Profit!

 

Edit: I guess this would require testing before a full implementation because the move body with reorient the .ipt file, and if the .ipt file is located based on the origin instead of work features, it would shift the file in your assembly it's used in.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes