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: 

Ilogic to handle Angle - imate Constraint

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Carthik_Babu
2337 Views, 6 Replies

Ilogic to handle Angle - imate Constraint

Hi, 

I need to control the orientation of the Tube & Fitting. I found Imate works well for mate & insert constraint, but angle constraint does not works well.

I have attached the assembly file along with this post. Kindly follow the procedure as shown in the below image and let me know, where i am going wrong in the coding. 

 

Wiki helps has also defined "There is no pictured solution for an Angle constraint."

http://wikihelp.autodesk.com/Inventor/enu/2012/Help/0073-Autodesk73/0460-Assembli460/0461-Build_as46...

 

 

Kindly ping me, is there is any other possible way to make angle constraint by ilogic.

 

Help: Kindly check the below link

http://adndevblog.typepad.com/manufacturing/2013/01/inventor-eulerian-angles-of-assembly-component.h...

 & let me know is there is any possible way to do vise versa. ie, to allocate the angle to the inserted component based on xyz coordintates on Matrix.

 

Ilogic-Pipe-ipart&imate.png

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
6 REPLIES 6
Message 2 of 7

Inventor API supports iMate functionality.  You may create iMates and change their parameters.  For example, you may query and change angle parameter value for angle constraint (d175 in your assembly).  
Please look at the iMate Result Creation API Sample in Inventor API Help. 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

Hi,

I am in the process of automation. I can get information of the component placed in the assembly by 

ThisApplication.CommandManager.Pick

as shown in the function 

Function Add_imate_const()

In that function i call  Function

DoiMates

to creat imate automatically between two components which has been selected by user. 

 

But i would like to know, how to get information of the Constraint automatically (d174,d175) by some ilogic command.

 

I can delete last created composite constraint by 

oiMateResults.Delete

Command. But i would like to know, how to get details of the constraint created automatically.

 

Kindly find below the code, which i have used in my assembly

 

Function Add_imate_const()
Dim oConstraint As iMateResult
Dim comp1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select First Component to constraint:")
Dim comp2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select Second Component to constraint:")
Face=InputListBox("Select Face name", MultiValue.List("Face"), Face, Title := "Select Face_name", ListName := "Select Face_name")
Face_Ang=InputListBox("Select Face_Ang name", MultiValue.List("Face_Ang"), Face_Ang, Title := "Select Face_Ang_name", ListName := "Select Face_Ang_name")
icomposite_name = Face & "-" & Face_Ang
'icomposite_name= InputListBox("Select constraint name", MultiValue.List("icomposite_name"), icomposite_name, Title := "Select icomposite_name", ListName := "Select icomposite_name")
'
Constraint_sup(comp1)
'
Constraint_sup(comp2)
DoiMates (comp1,comp2,icomposite_name)
'Constraint_un_sup(comp1)
'
Constraint_un_sup(comp2)
accept = InputRadioBox("Accept or Reject the last constraint", "Accept", "Reject", accept, Title := "Accept or Reject last constraint")
While accept <> True
oiMateResults.Delete
comp1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select First Component to constraint:")
comp2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select Second Component to constraint:")
ThisApplication.CommandManager.StartCommand(2179)
Face=InputListBox("Select Face name", MultiValue.List("Face"), Face, Title := "Select Face_name", ListName := "Select Face_name")
Face_Ang=InputListBox("Select Face_Ang name", MultiValue.List("Face_Ang"), Face_Ang, Title := "Select Face_Ang_name", ListName := "Select Face_Ang_name")
icomposite_name = Face & "-" & Face_Ang
DoiMates (comp1,comp2,icomposite_name)
accept = InputRadioBox("Accept or Reject the last constraint", "Accept", "Reject", accept, Title := "Accept or Reject last constraint")
If accept <> True
oiMateResults.Delete
End If
End While

End Function
Public Dim oiMateResults As iMateResult
Public Sub DoiMates(BaseComponent As ComponentOccurrence, SecondComponent As ComponentOccurrence,icomposite_name1 As String)
Dim oiMateDef1 As iMateDefinition
Dim oiMateDef2 As iMateDefinition

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
For Each oiMateDef1 In BaseComponent.iMateDefinitions
If oiMateDef1.Name = icomposite_name1 Then Exit For
Next
If oiMateDef1 Is Nothing Then
MsgBox ("Missing iMate information on Base Component" )
Exit Sub
End If

For Each oiMateDef2 In SecondComponent.iMateDefinitions
If oiMateDef2.Name = icomposite_name1 Then Exit For
Next
If oiMateDef2 Is Nothing Then
MsgBox ("Missing iMate information on Next Component", vbCritical)
Exit Sub
End If

oiMateResults = oAsmCompDef.iMateResults.AddByTwoiMates(oiMateDef1, oiMateDef2)
'MsgBox(oiMateResults.ParentComposite)
MsgBox(oiMateResults.Name)
Last_constraint_name=oiMateResults.Name

End Sub

Thanks in advance

 

 

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 4 of 7

Assume you have got the reference to the AngleConstraint object.  

Then its AngleConstraint.Angle property returns the Parameter object that controls the angle value of this constraint (d175). So you may find the angle value.

You can get many other details as well:   both occurrences, BRep entities and their geometry, iMateResult, visibility, Suppressed status and so on.  Please refer Inventor API Help for the detailed description.

Cheers,


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 7

Can you please provide some example code on how  "AngleConstraint.Angle"  is used in code.

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/
Message 6 of 7

The following sample set angle value in angle constraint to 45 deg.

Private Sub AngleConstraint()

    Dim oAssyDef As AssemblyComponentDefinition
    Set oAssyDef = ThisApplication.ActiveDocument.ComponentDefinition
    
    Dim Pi As Double:  Pi = Math.Atn(1) * 4
    
    Dim oOccs As ComponentOccurrences
    Set oOccs = oAssyDef.Occurrences
    
    Dim oOcc As ComponentOccurrence
    Set oOcc = oOccs.ItemByName("ANSI-ASME B36.19M Pipe 1-8 - Schedule 10S:1")
    Dim oAngleConstr As AngleConstraint
    Set oAngleConstr = oOcc.Constraints.Item(1)
    
    Dim AnglePar As ModelParameter
    Set AnglePar = oAngleConstr.Angle
    Debug.Print "Initial angle = " & AnglePar.Value * 180 / Pi
    
    AnglePar.Value = 45 * Pi / 180
    oAssyDef.Document.Update
    
    Debug.Print "Initial angle = " & AnglePar.Value * 180 / Pi

    Beep
End Sub

 ANGLE Constraint.png

 

In this case angle is controlled by the model parameter "d175":

d175 Value.png


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 7 of 7

Dear Sir, Thank you very much for the Solution.

For those who search for the same:
I have updated the model and saved it in "Grabcad website" for free access of this Example files.
http://grabcad.com/library/ilogic-ipart-and-imate-1
and made video presentation too for the same, to understand how ilogic is used handle ipart and imate for inventor automation.
http://youtu.be/NGpLJYfzM9U
Do check out.....hope it will be useful for beginners like me.

Carthik Babu M.S, Asst Manager - Machine Building,
Gabriel India Ltd,Hosur, TN, INDIA
Email:carthik_ms@yahoo.co.in ,
https://grabcad.com/carthik-1/projects
"May all beings be happy" http://www.dhamma.org/

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

Post to forums  

Autodesk Design & Make Report