Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Frame Generator - Miter and cut detail - customized BOM

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
Anonymous
3296 Views, 25 Replies

Frame Generator - Miter and cut detail - customized BOM

Hi Guys,

This One is a good one for all you cleaver i Logic people.

 

I have a BOM that I want to use the Cutdetals from frame generator.

My need is for the figure of text that is created is not how my bosses want to use it.

The angle is created from the back edge of the box but typically the saw man will move the saw from 0 deg's which is 90 deg out from the the angle that inventor created. (hopefully you know what I mean)

so where Cutdetail says 51.33deg in my bom i want it to say 38.67deg.

first how would i do this???

also I want to bring the details into the Part number column to read as I have manually entered below.

Any Ideas on how to do this??

TEST BOM.JPG 

25 REPLIES 25
Message 21 of 26
chandra.shekar.g
in reply to: Anonymous

@Anonymous,

 

Try this.

Sub Main() 
    ' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument  
	 
    ' Get the assembly component definition. 
    Dim oAsmDef As WeldmentComponentDefinition  
    oAsmDef = oAsmDoc.ComponentDefinition 

    ' Get all of the leaf occurrences of the assembly. 
    Dim oLeafOccs As ComponentOccurrencesEnumerator 
    oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences 

    ' Iterate through the occurrences and print the name. 
	Dim cnt As Integer 
	cnt = 0
	Dim total As Double  
	 
	Dim oOcc As ComponentOccurrence
	For Each oOcc In oLeafOccs
		If oOcc.DefinitionDocumentType = kPartDocumentObject Then
            Dim oReferDoc As PartDocument
            oReferDoc = oOcc.ReferencedDocumentDescriptor.ReferencedDocument
                   
            Dim oProp As Inventor.Property
            For Each oProp In oReferDoc.PropertySets.Item(4)
            
                If oProp.DisplayName = "CUTDETAIL1" Then
					Dim oName As String 
					oName = oProp.Name
					
                    Dim sawAngle As String
                    sawAngle = oProp.Value 
					
					Dim angle(2) As String 
					angle = sawAngle.Split(" ")
			
					If angle(0) = "Miter" Then
						
						Dim needAngle As Double
						needAngle = 90 - Convert.ToDouble(angle(1))
						 
						oReferDoc.PropertySets.Item(4).Item(oName).Value = "Miter " + needAngle.ToString + " deg"
					
					End If 
                End If
                
            Next 
            
        End If
		 
		 
	Next   

End Sub

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 22 of 26
Anonymous
in reply to: chandra.shekar.g

Hi Chandra,

This code appears to work perfect in our weldment template.

Thanks 

Message 23 of 26
chandra.shekar.g
in reply to: Anonymous

@Anonymous,

 

If code is working, click on "Accept solutions"

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 24 of 26

Hi @chandra.shekar.g 

 

First of all, thank you for the solution it looks nice.

 

Let me say that once I executed the rule, the second time it does not update the information. It seems like the rule is not running.

 

Do you have any idea to fix that?

 

Thank you,

Message 25 of 26
Anonymous
in reply to: chandra.shekar.g

CUT ANGLECUT ANGLE

 

 

Capture2.PNGCapture3.PNG

 

hello

 

i write the rule in the assembly but it does not change the inverse angle on the BOM when i execute it

 

i'm french, i  replace 'CUTDETAIL1" by 'DETAILDECOUPE1' .....

 

Please could you help me.

 

i have ever write code in javascript and i don't  find console to execute the code and see if it works or executed and 

 

you will find my assembly to see 

 

 

Sub main()
	
' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument  
	 
    ' Get the assembly component definition. 
    Dim oAsmDef As AssemblyComponentDefinition  
    oAsmDef = oAsmDoc.ComponentDefinition 

    ' Get all of the leaf occurrences of the assembly. 
    Dim oLeafOccs As ComponentOccurrencesEnumerator 
    oLeafOccs = oAsmDef.Occurrences.AllLeafOccurrences 

    ' Iterate through the occurrences and print the name. 
	Dim cnt As Integer 
	cnt = 0
	Dim total As Double  
	 
	Dim oOcc As ComponentOccurrence
	For Each oOcc In oLeafOccs
		If oOcc.DefinitionDocumentType = kPartDocumentObject Then
            Dim oReferDoc As PartDocument
            oReferDoc = oOcc.ReferencedDocumentDescriptor.ReferencedDocument
                   
            Dim oProp As Inventor.Property
            For Each oProp In oReferDoc.PropertySets.Item(4)
            
                 If oProp.DisplayName.Contains("DETAILDECOUPE2") = True Then
					Dim oName As String 
					oName = oProp.Name
					
                    Dim sawAngle As String
                    sawAngle = oProp.Value 
					
					Dim angle(1) As String 
					angle = sawAngle.Split(" ")
			
					Select Case angle(0)
					Case "Angle de coupe" 
						If angle(2) <> 90 Then 
						needAngle = 90 - Convert.ToDouble(angle(2))
						oReferDoc.PropertySets.Item(4).Item(oName).Value = "Angle de coupe " + needAngle.ToString + " deg"
					End If
					
					Case "Coupe d'onglet" 
						If angle(1) <> 90 Then 
						needAngle = 90 - Convert.ToDouble(angle(1))
						oReferDoc.PropertySets.Item(4).Item(oName).Value = "Coupe d'onglets " + needAngle.ToString + " deg"
					End If
                	End Select
				End If
            Next 
        End If	 
	Next   
	
End Sub

  

Message 26 of 26

hi, how do you run this script?

 

Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report