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.ControlDefini
tions.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...
Solved! Go to Solution.
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?
this thread has an example to add an button
Sorry, but that doesn't even discuss the problem I'm having, let alone solve my problem.
Screenshot of the button on my screen attached.
Did you edit my code at all? If so, what did you change?
I referenced the code in the link.
Dim picture AsIPictureDisp
picture = Microsoft.VisualBasic.Compatibility.VB6.ImageToIPi
oButtonActivate = controlDefs.AddButtonDefinition( _
"HDAL Label Maker", _
"HDAL Label", picture)
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!
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
'MsgBox("Button works successfully")
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,
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register