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: 

My First Add-In - Can't define ButtonDefinition

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
gerhick
1453 Views, 10 Replies

My First Add-In - Can't define ButtonDefinition

Hi all,

 

I've finally decided to take the plunge and give add-ins a go, but so far it's not going well.

 

I've surrounded myself with printouts from Mr Ekins, poured over the SDK sample add-ins and scoured the discussion forums, but I've come up with naught...

 

The Code i've got is shown below (albeit a bit truncated). I'm pretty sure that the error is with the arguments for 'AddButtonDefinition', but I can't figure it out, it matches one of the Samples perfectly (where it matters).

Private m_inventorApplication As Inventor.Application
Private m_ClientID As String
Private WithEvents oButtonActivate As Inventor.ButtonDefinition

Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

Try oButtonActivate = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition( _ "HDAL Label Maker", "ActivateHDALLabelMaker", CommandTypesEnum.kShapeEditCmdType, _ m_ClientID, "Activates the HDAL Label Maker.", "HDAL Label Maker", icoHDALLabelMaker16x16, _ icoHDALLabelMaker32x32)
Catch ex As Exception
                MsgBox(ex.ToString & vbCrLf & m_ClientID)
End Try

 I've attached an image of the error thrown by 'Catch ex as Exception' incase it offers any clues...

 

Any assistance would be greatly appreciated. I've spent WAY too much time trying to figure this one out...

 

Cheers

 

___________________________________________
Gerrard Hickson
Inventor CAD Administrator || Autodesk Inventor 2012 Certified Professional
Autodesk AutoCAD 2012 Certified Professional|| Bachelor of Technology (Mechanical)

PointZero Design and Drafting
10 REPLIES 10
Message 2 of 11
gerhick
in reply to: gerhick

Okay, I got it to work by removing the icons from the button definition. But I'm not sure how to fix it...

 

I found the following metion in an older document by Neil Munro 


From Moving Up to Autodesk Inventor® Add-In:
Icons cannot be passed between processes with the AddButtonDefinition method, so an error is generated

 The doc is located here: http://www.widom-assoc.com/AU-MA13-3.pdf

 

Does anyone have any suggestions about how to resolve this issue? How can I get my button definition to pass my Icons to Inventor?

 

Cheers

___________________________________________
Gerrard Hickson
Inventor CAD Administrator || Autodesk Inventor 2012 Certified Professional
Autodesk AutoCAD 2012 Certified Professional|| Bachelor of Technology (Mechanical)

PointZero Design and Drafting
Message 3 of 11
cean_au
in reply to: gerhick
Message 4 of 11
gerhick
in reply to: cean_au

Sorry, but that doesn't even discuss the problem I'm having, let alone solve my problem.

___________________________________________
Gerrard Hickson
Inventor CAD Administrator || Autodesk Inventor 2012 Certified Professional
Autodesk AutoCAD 2012 Certified Professional|| Bachelor of Technology (Mechanical)

PointZero Design and Drafting
Message 5 of 11
cean_au
in reply to: gerhick

this is what i got.

Message 6 of 11
gerhick
in reply to: cean_au

Screenshot of the button on my screen attached.

 

Did you edit my code at all? If so, what did you change?

___________________________________________
Gerrard Hickson
Inventor CAD Administrator || Autodesk Inventor 2012 Certified Professional
Autodesk AutoCAD 2012 Certified Professional|| Bachelor of Technology (Mechanical)

PointZero Design and Drafting
Message 7 of 11
cean_au
in reply to: gerhick

I referenced the code in the link.

           

Dim picture AsIPictureDisp

 

            picture = Microsoft.VisualBasic.Compatibility.VB6.ImageToIPictureDisp(

My.Resources.BweSetup)

            oButtonActivate = controlDefs.AddButtonDefinition( _

         

"TANK", _

         

"ActivateHDALLabelMaker", _

         

CommandTypesEnum.kShapeEditCmdType, _

         

"{06522786-038f-494f-9555-2d17a0302529}", _

         

"HDAL Label Maker", _

         

"HDAL Label", picture)


Message 8 of 11
gerhick
in reply to: cean_au

Well I'll be damned.. it worked that time... I know I tried it before 'cause the code was there, just commented out...

 

Oh well... Thanks for your help!

 

Cheers

___________________________________________
Gerrard Hickson
Inventor CAD Administrator || Autodesk Inventor 2012 Certified Professional
Autodesk AutoCAD 2012 Certified Professional|| Bachelor of Technology (Mechanical)

PointZero Design and Drafting
Message 9 of 11
cean_au
in reply to: gerhick

do you know how to assign an action to a button, like use MsgBox to show a message?

Message 10 of 11
gerhick
in reply to: cean_au

I've added this code into my 'Public Class StandardAddinServer' code. Immediately below #COM Registration.

 

Private Sub oButtonActivate_OnExecute(ByVal Context As Inventor.NameValueMap) HandlesoButtonActivate.OnExecute

 

'All your Code goes here

 

Dim frmLabelInput AsNewfrmLabelInput

frmLabelInput.Show()

'MsgBox("Button works successfully")

EndSub

 

Where oButtonActivate is declared as follows:

 

Private WithEvents oButtonActivate As Inventor.ButtonDefinition

 

and it is defined as my ControlDefinitions.AddButtonDefinition which gives me the button on my Ribbon.

 

Let me know if that helps,

 

 

___________________________________________
Gerrard Hickson
Inventor CAD Administrator || Autodesk Inventor 2012 Certified Professional
Autodesk AutoCAD 2012 Certified Professional|| Bachelor of Technology (Mechanical)

PointZero Design and Drafting
Message 11 of 11
cean_au
in reply to: gerhick

cool.

 

thx

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

Post to forums