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: 

Buttons for materials...

1 REPLY 1
Reply
Message 1 of 2
Anonymous
191 Views, 1 Reply

Buttons for materials...

I have created the following materials in my styles editor:

A36 STL
304 SS
304L SS
316 SS
316L SS

I would like to create buttons for each that will set the part I have open to one of these materials without having to open iProperties, etc.

Anyone have anything on this?
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

Below is some code for several VBA macros. If you insert these into your
default VBA project (the one defined using the File tab of the Application
Options command) you can use the Customize command to insert a button for
each one in any toolbar. If you don't have Expert mode enabled, then the
name of the macro will display next to each button. If you do have expert
mode on then you'll only see the icon, which will be the same for all of the
buttons. The tooltip will show the name of the macro. You can supply your
own icon too if you want following the rules below.

To get consistent results you should use specific sizes for the bitmaps. In
some cases Inventor is able to scale any size bitmap and use it for the
button, but this can result in skewed images and does not always work.
Within Inventor the user can specify whether to use large or small icons for
buttons. Because of this you can supply both a large and small icon. Small
buttons are the default size. The small bitmap should be 15 pixels high by
16 pixels wide and the large bitmap should be 22 pixels high by 24 pixels
wide. The number of colors does not matter.

In order for Inventor to associate a bitmap with a particular macro, it uses
the name of the bitmap. The naming scheme is:

ModuleName.SubName.IconSize.bmp

For example, here are the filenames that are used for the small and large
icons for a macro called "EditParameter".

Module1.EditParameter.Small.bmp
Module1.EditParameter.Large.bmp

The names are not case sensitive so "module1.editparameter.small.bmp" will
also work. Besides having the correct name, the bitmap file must also be in
the same directory as the default vba project ivb file.


Public Sub Material_A36_STL()
Call SetMaterial("A36 STL")
End Sub

Public Sub Material_304_SS()
Call SetMaterial("304 SS")
End Sub

Public Sub Material_304_L_SS()
Call SetMaterial("304 L SS")
End Sub

Public Sub Material_316_SS()
Call SetMaterial("316 SS")
End Sub

Public Sub Material_316_L_SS()
Call SetMaterial("316 L SS")
End Sub

Private Sub SetMaterial(ByVal MaterialName As String)
On Error Resume Next
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveEditObject
If Err Then
MsgBox "A part document must be active when running this command."
Exit Sub
End If

oDoc.ComponentDefinition.Material = oDoc.Materials.Item(MaterialName)
If Err Then
MsgBox "Error setting the material to """ & MaterialName & """"
End If
End Sub
--
Brian Ekins
Autodesk Inventor API

wrote in message news:5199154@discussion.autodesk.com...
I have created the following materials in my styles editor:

A36 STL
304 SS
304L SS
316 SS
316L SS

I would like to create buttons for each that will set the part I have open
to one of these materials without having to open iProperties, etc.

Anyone have anything on this?

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

Post to forums  

Autodesk Design & Make Report