0% found this document useful (0 votes)
120 views5 pages

Creating A Ribbon Item For Inventor - Manufacturing DevBlog

The document describes how to create a custom ribbon tab, panel, and button for Autodesk Inventor. It explains how to add a ribbon item definition, create the ribbon tab and panel, add a button to the panel, and handle the button click event. It also provides sample code in Visual Basic.NET to demonstrate this process.

Uploaded by

tiele_barcelos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views5 pages

Creating A Ribbon Item For Inventor - Manufacturing DevBlog

The document describes how to create a custom ribbon tab, panel, and button for Autodesk Inventor. It explains how to add a ribbon item definition, create the ribbon tab and panel, add a button to the panel, and handle the button click event. It also provides sample code in Visual Basic.NET to demonstrate this process.

Uploaded by

tiele_barcelos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

21/01/2017

CreatingaRibbonitemforInventorManufacturingDevBlog

ManufacturingDevBlog
(http://adndevblog.typepad.com/manufacturing/)

TheresourceforsoftwaredevelopersworkingwithDesign,LifecycleandSimulationtechnologiesfromAutodesk.

07/03/2013

CreatingaRibbonitemforInventor
ByAugustoGoncalves(http://adndevblog.typepad.com/manufacturing/augustogoncalves.html)
HereisaquicksampleonhowcreateanewRibbonTab,PanelandButtonwithIcononInventor.Althoughtherearesomesamplesontheblog,thisjustsummarizesthewholeprocess.
TheIconusedontheRibbonbuttoncanbeplacedinsidetheproject,inthiscaseisevenbetterwhenitsembeddedontheproject,thatwayyourpluginjustneedtobedeliveredwiththe
DLLfile(noadditional.icofiles).Todoso,putthe.icoontheprojectfolder,includeontheproject,thengotothefilepropertiesandselectBuildAction.ThemethodGetICOResource
receivetheresourcename,usuallytheProjectName.FileName.ico(seesamplecallforthismethod)

(http://adndevblog.typepad.com/.a/6a0167607c2431970b01901e1c1dbc970bpi)
Nowitstimetocreatethecode.Thefollowingsampleshowitforasinglebutton,justplaceitinsidetheActivatemethodforaquicktest.
PublicSubActivate(_
ByValaddInSiteObjectAsInventor.ApplicationAddInSite,_
ByValfirstTimeAsBoolean)_
ImplementsInventor.ApplicationAddInServer.Activate
'Inventorapplication
m_inventorApplication=addInSiteObject.Application

'getthecommandmanagercontroldefinition
DimconDefsAsInventor.ControlDefinitions=_
m_inventorApplication._
CommandManager.ControlDefinitions

'ourcustomcommandID
DimidCommand1AsString="ID_COMAND_1"

Try
'trygettheexistingcommanddefinition
_defComando1=conDefs.Item(idCommand1)
CatchexAsException
'orcreateit
_defComando1=conDefs.AddButtonDefinition(_
"Command1",idCommand1,_
CommandTypesEnum.kEditMaskCmdType,_
Guid.NewGuid().ToString(),_
"Command1description",_
"Command1Tooltip",_
GetICOResource("ProjetName.StdIcon.ico"),_
GetICOResource("ProjetName.Large.ico"))
EndTry

If(firstTime)Then
If(m_inventorApplication.UserInterfaceManager.
InterfaceStyle=
InterfaceStyleEnum.kRibbonInterface)Then

'1.accesstheZeroDocribbon
DimribbonPartAsInventor.Ribbon=
m_inventorApplication.
UserInterfaceManager.
Ribbons.Item("ZeroDoc")

'2.createourcustomtab
DimtabSampleBlogAsInventor.RibbonTab=
ribbonPart.RibbonTabs.Add(_
"SampleBlog",_
"TAB_SAMPLE_BLOG",_
Guid.NewGuid().ToString())

http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html

1/5

21/01/2017

CreatingaRibbonitemforInventorManufacturingDevBlog

'3.criarumpainel
DimpnlMyCommandsAsInventor.RibbonPanel=
tabSampleBlog._
RibbonPanels.Add("MyCommand",_
"PNL_MY_COMMANDS",_
Guid.NewGuid().ToString())

'4.colocarobotonopainel
pnlMyCommands.CommandControls.AddButton(_defComando1,True)
EndIf
EndIf

'registerthemethodthatwillbeexecuted
AddHandler_defComando1.OnExecute,AddressOfCommand1Method

EndSub
'mustbedeclaredattheclasslevel
Private_defComando1AsInventor.ButtonDefinition
PrivateSubCommand1Method()
'ToDo:doyourcodehere
EndSub

PrivateFunctionGetICOResource(_
ByValicoResourceNameAsString)AsObject
DimassemblyNetAsSystem.Reflection.Assembly=_
System.Reflection.Assembly.GetExecutingAssembly()
DimstreamAsSystem.IO.Stream=_
assemblyNet.GetManifestResourceStream(icoResourceName)
DimicoAsSystem.Drawing.Icon=_
NewSystem.Drawing.Icon(stream)
ReturnPictureDispConverter.ToIPictureDisp(ico)
EndFunction

ThePictureDispConverterconverterisbasedonthisAUclassbyPhilippeLeefsma(http://adndevblog.typepad.com/manufacturing/2013/02/designpatternsappliedtotheinventor
api.html).BelowisthepiecerequiredhereconvertedtoVB.NET
PublicNotInheritableClassPictureDispConverter
<DllImport("OleAut32.dll",
EntryPoint:="OleCreatePictureIndirect",
ExactSpelling:=True,PreserveSig:=False)>_
PrivateSharedFunctionOleCreatePictureIndirect(_
<MarshalAs(UnmanagedType.AsAny)>picdescAsObject,_
ByRefiidAsGuid,_
<MarshalAs(UnmanagedType.Bool)>fOwnAsBoolean_
)AsIPictureDisp
EndFunction

SharediPictureDispGuidAsGuid=GetType(_
IPictureDisp).GUID

PrivateNotInheritableClassPICTDESC
PrivateSubNew()
EndSub
'PictureTypes
PublicConstPICTYPE_UNINITIALIZEDAsShort=1
PublicConstPICTYPE_NONEAsShort=0
PublicConstPICTYPE_BITMAPAsShort=1
PublicConstPICTYPE_METAFILEAsShort=2
PublicConstPICTYPE_ICONAsShort=3
PublicConstPICTYPE_ENHMETAFILEAsShort=4

<StructLayout(LayoutKind.Sequential)>_
PublicClassIcon
FriendcbSizeOfStructAsInteger=Marshal.SizeOf(_
GetType(PICTDESC.Icon))
FriendpicTypeAsInteger=PICTDESC.PICTYPE_ICON
FriendhiconAsIntPtr=IntPtr.Zero
Friendunused1AsInteger
Friendunused2AsInteger

FriendSubNew(icon__1AsSystem.Drawing.Icon)
Me.hicon=icon__1.ToBitmap().GetHicon()
EndSub
EndClass

<StructLayout(LayoutKind.Sequential)>_
PublicClassBitmap
FriendcbSizeOfStructAsInteger=Marshal.SizeOf(_

http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html

2/5

21/01/2017

CreatingaRibbonitemforInventorManufacturingDevBlog

GetType(PICTDESC.Bitmap))
FriendpicTypeAsInteger=PICTDESC.PICTYPE_BITMAP
FriendhbitmapAsIntPtr=IntPtr.Zero
FriendhpalAsIntPtr=IntPtr.Zero
FriendunusedAsInteger

FriendSubNew(bitmap__1AsSystem.Drawing.Bitmap)
Me.hbitmap=bitmap__1.GetHbitmap()
EndSub
EndClass
EndClass

PublicSharedFunctionToIPictureDisp(_
iconAsSystem.Drawing.Icon_
)AsIPictureDisp
DimpictIconAsNewPICTDESC.Icon(icon)
ReturnOleCreatePictureIndirect(pictIcon,_
iPictureDispGuid,True)
EndFunction

PublicSharedFunctionToIPictureDisp(_
bmpAsSystem.Drawing.Bitmap_
)AsIPictureDisp
DimpictBmpAsNewPICTDESC.Bitmap(bmp)
ReturnOleCreatePictureIndirect(pictBmp,_
iPictureDispGuid,True)
EndFunction
EndClass

Postedat01:58PMinAugustoGoncalves(http://adndevblog.typepad.com/manufacturing/augustogoncalves/),Inventor(http://adndevblog.typepad.com/manufacturing/inventor/)|
Permalink(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html)
(http://twitter.com/share?url=http%3A%2F%2Fbit.ly%2F10A5LFU&text=Creating%20a%20Ribbon%20item%20for%20Inventor)

(https://plus.google.com/share?

url=http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html)

(http://www.facebook.com/sharer.php?
u=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2013%2F07%2Fcreatingaribbonitemforinventor.html)

Comments
HeatherSharp(https://www.facebook.com/heather.sharp.7399)said...

SorryAugusto,butIcannotgetthisrunningforthelifeofme!
IamjustlearningVisualBasic,andneedabitmorehelp.Couldyoupleasesendmethezippedproject?IcanthenopenitinVisualStudioandlookattheguts,andseewhyitwasnot
workingforme.Thankyouverymuch!

Reply

10/09/2013at11:17AM(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html#comment6a0167607c2431970b019affe358b7970b)

AugustoGoncalves(http://profile.typepad.com/6p0168e7e7c9dd970c)saidinreplytoHeatherSharp(https://www.facebook.com/heather.sharp.7399)...

HiHeather,
Thispostactuallyreferstoanotherpostwhereasampleisavailable(betweenthefirstandsecondsamplecode,thereisasmalltextonit).
Nowthebaseposthavea.zipwithsamplecode(amongotherthings):http://adndevblog.typepad.com/cp2675designpatternsappliedtotheautodeskinventorapi.zip
(http://adndevblog.typepad.com/cp2675designpatternsappliedtotheautodeskinventorapi.zip)
Regards,
AugustoGoncalves
Reply 10/14/2013at01:30PM(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html#comment6a0167607c2431970b019b0006b8e7970b)

HeatherSharp(https://www.facebook.com/heather.sharp.7399)saidinreplytoAugustoGoncalves(http://profile.typepad.com/6p0168e7e7c9dd970c)...

Thankyou!
Reply 10/22/2013at04:51PM(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html#comment6a0167607c2431970b019b0039bdb3970d)

RANJANsaidinreplytoAugustoGoncalves(http://profile.typepad.com/6p0168e7e7c9dd970c)...

http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html

3/5

21/01/2017

CreatingaRibbonitemforInventorManufacturingDevBlog

HiAugusto,
CouldyouexplainhowtouseWPFformforInventorAddin?
Reply 11/17/2015at05:17AM(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html#comment6a0167607c2431970b01b8d1777487970c)

gildaluciasaid...

PrezadoAugustoGonalves,estoutentandofazerumaguiacustomizadacom2painisealgunscomandosnoRevit2014.FaoissoseguindoohelpdaAutodesk.Jbaixeimuitos
exemploseconsulteigruposdediscusso,semexito.UsooMicrosoftVisualC#2010Express.Nohaerrosdecompilao.Guardooarquivomanifestonolocalcorreto,masopluginno
executanoRevit.QuandoabrooRevit,surgeumamensagemdeerroassim:ORevitnopodeexecutaroaplicativoexternoSampleApplication.Entreemcontatocomoprovedorpara
pedirajuda...
Exibirdetalhes
NofoipossvelcarregarotipoAddPanel.CsAddPaneldoassemblyAddPanel,version=1.0.0.0,Culture=neutral,PublicKeyToken=null.
ComosigoexatamenteospassosdoexemploAutodesk,noseioporquedoproblema.Haveriacondiodemeenviarumcdigocompletoquefuncione,paraesseexemplo,paraqueeu
comparecomomeuedescubraoerro?Agradeo.
Reply 03/05/2014at08:24AM(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html#comment6a0167607c2431970b01a3fccd0ed0970b)

AugustoGoncalves(http://profile.typepad.com/6p0168e7e7c9dd970c)saidinreplytogildalucia...

Gilda
I'llreplydirectlytoyoubyemail.
Cheers,
AugustoGoncalves
Reply 03/10/2014at12:06PM(http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html#comment6a0167607c2431970b01a51181085d970c)

Commentbeloworsigninwith Typepad(http://www.typepad.com/sitelogin?uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2013%2F07%2Fcreatinga
ribbonitemfor
inventor.html&fp=bda205509aa4b23a35d245752189fd8c&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&post_uri=http://adndevblog.typepad.com/manufacturing/2013/
aribbonitemforinventor.html) Facebook(http://www.typepad.com/sitelogin?uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2013%2F07%2Fcreatinga
ribbonitemfor
inventor.html&fp=bda205509aa4b23a35d245752189fd8c&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=facebook&post_uri=http://adndevblog.typepad.com/ma
aribbonitemforinventor.html) Twitter(http://www.typepad.com/sitelogin?uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2013%2F07%2Fcreatinga
ribbonitemfor
inventor.html&fp=bda205509aa4b23a35d245752189fd8c&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=twitter&post_uri=http://adndevblog.typepad.com/manu
aribbonitemforinventor.html) Google+(http://www.typepad.com/sitelogin?uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2013%2F07%2Fcreatinga
ribbonitemfor
inventor.html&fp=bda205509aa4b23a35d245752189fd8c&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=gplus&post_uri=http://adndevblog.typepad.com/manuf
aribbonitemforinventor.html)andmore...(http://www.typepad.com/sitelogin?uri=http%3A%2F%2Fadndevblog.typepad.com%2Fmanufacturing%2F2013%2F07%2Fcreatinga
ribbonitemfor
inventor.html&fp=bda205509aa4b23a35d245752189fd8c&view_uri=http%3A%2F%2Fprofile.typepad.com%2F&via=blogside&service=openid&post_uri=http://adndevblog.typepad.com/manu
aribbonitemforinventor.html)

(URLsautomaticallylinked.)

Emailaddressisnotdisplayedwithcomment.

Name
EmailAddress
WebSiteURL
Post Preview

(http://www.typepad.com/)

http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html

4/5

21/01/2017

CreatingaRibbonitemforInventorManufacturingDevBlog

ManufacturingDevBlog(http://adndevblog.typepad.com/manufacturing/)

http://adndevblog.typepad.com/manufacturing/2013/07/creatingaribbonitemforinventor.html

5/5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy