Insert part macro button.

Insert part macro button.

Anonymous
Not applicable
882 Views
7 Replies
Message 1 of 8

Insert part macro button.

Anonymous
Not applicable
Dear all,

I used to have in autocad my own customization for inserting blocks with the
"-insert" command. all this with nice icons etc...

I would like to do the same in Inventor
So far i think i need to create macros for each item and insert each of them
in my customized submenu as a button which i'm fine with.

my problem is: i need a code for the macro. (since we still haven't got a
"record macro function" i'm stuck!)

I'm on inventor 10 but obviously need something that will work in future
version.

Many thanks in advance.

Rhum
0 Likes
883 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
There's a sample in Programming Help, to get you started.
In the Help pulldown menu, go to Programming Help, then Help Samples at the
top.
The first one is Assembly Add Occurrence

Mike

"Rom Poteaux" <> wrote in message news:[email protected]...
Dear all,

I used to have in autocad my own customization for inserting blocks with the
"-insert" command. all this with nice icons etc...

I would like to do the same in Inventor
So far i think i need to create macros for each item and insert each of them
in my customized submenu as a button which i'm fine with.

my problem is: i need a code for the macro. (since we still haven't got a
"record macro function" i'm stuck!)

I'm on inventor 10 but obviously need something that will work in future
version.

Many thanks in advance.

Rhum
0 Likes
Message 3 of 8

Anonymous
Not applicable
Mike,

Thanks for the answer...
This is a start for what i want...
the example given in the help positions the part automatically at 0,0,0. I
would like to be able to mouse click the position i want.
which part of the code do i need to change and by what?

the code from the help with my changes is now:
"Sub Insert110DiaSingleSocket()
' 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("C:\WORKSPACE\Libraries\Bought
Outs\OSMA\16008.ipt", oMatrix)
End Sub





"Mike Maenpaa" wrote in message
news:[email protected]...
There's a sample in Programming Help, to get you started.
In the Help pulldown menu, go to Programming Help, then Help Samples at the
top.
The first one is Assembly Add Occurrence

Mike

"Rom Poteaux" <> wrote in message news:[email protected]...
Dear all,

I used to have in autocad my own customization for inserting blocks with the
"-insert" command. all this with nice icons etc...

I would like to do the same in Inventor
So far i think i need to create macros for each item and insert each of them
in my customized submenu as a button which i'm fine with.

my problem is: i need a code for the macro. (since we still haven't got a
"record macro function" i'm stuck!)

I'm on inventor 10 but obviously need something that will work in future
version.

Many thanks in advance.

Rhum
0 Likes
Message 4 of 8

Anonymous
Not applicable
look at the Samples under UI Customization => Selection Simple

you will need to incoporate the Interaction Events and SelectEvents

BTW, an alternative approach is to put your parts into a library folder for your project, then you can quickly Insert Component.. and browse to your library.
0 Likes
Message 5 of 8

Anonymous
Not applicable
Another option is to use PostPrivateEvents to pre-populate the filename
field in the 'Place Component' dialog and start the command. This lets you
pick the position of the occurrence in the assembly. However, just as with
the GUI workflow, the very first occurrence will be placed at the origin and
there is no initial control over its location.

Sub PlaceComponent()

ThisApplication.CommandManager.PostPrivateEvent kFileNameEvent,
"C:\temp\block.ipt"

Dim odef As ControlDefinition
Set odef =
ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyPlaceComponentCmd")

Call odef.Execute

End Sub

Sanjay-

wrote in message news:[email protected]...
look at the Samples under UI Customization => Selection Simple

you will need to incoporate the Interaction Events and SelectEvents

BTW, an alternative approach is to put your parts into a library folder for
your project, then you can quickly Insert Component.. and browse to your
library.
0 Likes
Message 6 of 8

lian_xie
Contributor
Contributor
Hi Sanjay:

Thanks for your help.
Could we use the similar ControlDefinitions.Item("DrawingSketchSymbolInsertCtxCmd") call to insert a sketched symbol onto the active sheet? If so, how to use PostPrivateEvets to pre-populate the SketchedSymbol Name?

Thanks,
Liansuo Xie
0 Likes
Message 7 of 8

Anonymous
Not applicable
The PostPrivateEvent works only for specific commands (mostly the ones that
require a file as input). It does not work with the sketched symbols
command. In your case, the ideal solution would have been to select
(programmatically) the sketched symbol definition of interest and issue the
"DrawingSketchSymbolInsertCtxCmd" command. This would prompt for a location
to place the sketched symbol. However, the API does not currently support
the selection of drawing resources (sketched symbol definitions included).
This is a high priority wishlist item for the next release.

The best you can do for now is to issue the "DrawingSymbolsCmd" and let the
user pick the symbol to place:

Dim odef As ControlDefinition
Set odef =
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingSymbolsCmd")

Call odef.Execute

Sanjay-

wrote in message news:[email protected]...
Hi Sanjay:

Thanks for your help.
Could we use the similar
ControlDefinitions.Item("DrawingSketchSymbolInsertCtxCmd") call to insert a
sketched symbol onto the active sheet? If so, how to use PostPrivateEvets
to pre-populate the SketchedSymbol Name?

Thanks,
Liansuo Xie
0 Likes
Message 8 of 8

Anonymous
Not applicable
I appreciate this but we are using the vault and i don't want to mess with
temp file location especially for library components.

we were advised to keep everything under 1 project folder.... "VAULT "!


wrote in message news:[email protected]...
look at the Samples under UI Customization => Selection Simple

you will need to incoporate the Interaction Events and SelectEvents

BTW, an alternative approach is to put your parts into a library folder for
your project, then you can quickly Insert Component.. and browse to your
library.
0 Likes