Inventor Customization

Reply
Mentor
gerhick
Posts: 174
Registered: ‎04-10-2008
Message 1 of 11 (678 Views)
Accepted Solution

My First Add-In - Can't define ButtonDefinition

678 Views, 10 Replies
07-20-2011 09:31 PM

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
Mentor
gerhick
Posts: 174
Registered: ‎04-10-2008
Message 2 of 11 (654 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-21-2011 03:08 PM 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
Valued Contributor
cean_au
Posts: 100
Registered: ‎07-11-2011
Message 3 of 11 (617 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 06:25 AM in reply to: gerhick
Mentor
gerhick
Posts: 174
Registered: ‎04-10-2008
Message 4 of 11 (608 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 02:11 PM 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
Valued Contributor
cean_au
Posts: 100
Registered: ‎07-11-2011
Message 5 of 11 (601 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 08:54 PM in reply to: gerhick

this is what i got.

Mentor
gerhick
Posts: 174
Registered: ‎04-10-2008
Message 6 of 11 (597 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 09:07 PM 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
Valued Contributor
cean_au
Posts: 100
Registered: ‎07-11-2011
Message 7 of 11 (594 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 09:18 PM 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)


Mentor
gerhick
Posts: 174
Registered: ‎04-10-2008
Message 8 of 11 (588 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 09:28 PM 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
Valued Contributor
cean_au
Posts: 100
Registered: ‎07-11-2011
Message 9 of 11 (585 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 09:42 PM in reply to: gerhick

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

Mentor
gerhick
Posts: 174
Registered: ‎04-10-2008
Message 10 of 11 (583 Views)

Re: My First Add-In - Can't define ButtonDefinition

07-27-2011 09:56 PM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube