Inserting parts into an assembly

Inserting parts into an assembly

Raider_71
Collaborator Collaborator
842 Views
5 Replies
Message 1 of 6

Inserting parts into an assembly

Raider_71
Collaborator
Collaborator
Hi,

I have come across two methods of inserting components into a Inventor assembly. They both seem to work well but I would like to know which one is the preferred method.
Secondly is there a way to insert the components but disabling the iMate feature. Using any one of the two methods Inventor places the components with iMate functionality on. Can this be disabled?

Thanks.

{code}
'Method1
oApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, destinationFile1)
oApp.CommandManager.StartCommand(Inventor.CommandIDEnum.kPlaceComponentCommand)


'Method2
oApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent, destinationFile1)
Dim oCtrlDef As ControlDefinition
oCtrlDef = oApp.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd")
oCtrlDef.Execute()

{code}
0 Likes
843 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Is there a reason you are accessing the built in commands instead of just
referencing the assembly component defintions ComponentOccurrences.Add
Method?

--
KWiKMcad
Kent Keller
"Raider_007" wrote in message news:6345511@discussion.autodesk.com...
Hi,

I have come across two methods of inserting components into a Inventor
assembly. They both seem to work well but I would like to know which one is
the preferred method.
Secondly is there a way to insert the components but disabling the iMate
feature. Using any one of the two methods Inventor places the components
with iMate functionality on. Can this be disabled?

Thanks.

{code}
'Method1
oApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent,
destinationFile1)
oApp.CommandManager.StartCommand(Inventor.CommandIDEnum.kPlaceComponentCommand)


'Method2
oApp.CommandManager.PostPrivateEvent(Inventor.PrivateEventTypeEnum.kFileNameEvent,
destinationFile1)
Dim oCtrlDef As ControlDefinition
oCtrlDef =
oApp.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd")
oCtrlDef.Execute()

{code}
0 Likes
Message 3 of 6

Raider_71
Collaborator
Collaborator
Hi Kent,
I have never used that (new programmer) but does it also give you the same interaction with Inventor compared to placing a component with the standard Inventor Place Component command? Thats why I am using it because you place it where you want using mouse clicks unless its the first part in an assembly obviously.

Pieter
0 Likes
Message 4 of 6

Anonymous
Not applicable
Pieter,

Below is the sample from help with the part rotation removed. You would
have to move it after it is placed. You could do the mouse placement, but
it would take a little more work.

Be sure to add a valid path to a part or assembly in the last line before
trying it.


Public Sub AddOccurrence()
' Set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
Set oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

' Create a matrix. A new matrix is initialized with an identity matrix.
Dim oMatrix As Matrix
Set oMatrix = oTG.CreateMatrix

''' ' Set the rotation of the matrix for a 45 degree rotation about the Z
axis.
''' Call oMatrix.SetToRotation(3.14159265358979 / 4, _
''' oTG.CreateVector(0, 0, 1), oTG.CreatePoint(0,
0, 0))
'''
''' ' Set the translation portion of the matrix so the part will be
positioned
''' ' at (3,2,1).
''' Call oMatrix.SetTranslation(oTG.CreateVector(3, 2, 1))

' Add the occurrence.
Dim oOcc As ComponentOccurrence
Set oOcc = oAsmCompDef.Occurrences.Add("Full Path to your File to add",
oMatrix)
End Sub


--
KWiKMcad
Kent Keller
"Raider_007" wrote in message news:6345820@discussion.autodesk.com...
Hi Kent,
I have never used that (new programmer) but does it also give you the same
interaction with Inventor compared to placing a component with the standard
Inventor Place Component command? Thats why I am using it because you place
it where you want using mouse clicks unless its the first part in an
assembly obviously.

Pieter
0 Likes
Message 5 of 6

Raider_71
Collaborator
Collaborator
Hi Kent yes I have seen that method before (never tried it myself) but I understood that it does not give you that interactive mouse placement. You say that it can be done. Have you got an axample?

Thanks for your help.
0 Likes
Message 6 of 6

Anonymous
Not applicable
If you want the interactive behavior when placing a part then starting the
command with an input file, like you're doing, is the best option. The two
methods you're using are essentially the same. They use PostPrivateEvent to
provide the filename and then start the Place Component command. The
StartCommand method used in your first example is obsolete. Getting the
desired ControlDefinition and calling its Execute method is the preferred
way of executing a command.

When executing the command you don't have control over it's various options,
like whether to use iMates or not. That is a downside of using this
approach.
--
Brian Ekins
Inventor API Product Designer
http://blogs.autodesk.com/modthemachine
0 Likes