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."
Kindly ping me, is there is any other possible way to make angle constraint by ilogic.
Help: Kindly check the below link
& 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.
Solved! Go to Solution.
Solved by Vladimir.Ananyev. Go to Solution.
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.
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
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,
Can you please provide some example code on how "AngleConstraint.Angle" is used in code.
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
In this case angle is controlled by the model parameter "d175":
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.