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: 

If statement between Part doc & Assembly doc

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
gcooper79
454 Views, 3 Replies

If statement between Part doc & Assembly doc

Hi All,

 

I'm trying to write my first VBA program for Inventor with very little programming experience.  I would like to create a userform which displays the materials list within a combobox.

 

The problem I have is that I would like the userform to remain open no matter which type of file is active. I would like the combobox to displayi the material list and current material when in a Part file and display N/A when in Assembly file.

 

I figure it would probably be an if statement, but I don't know how to configure it.

 

Any help would be gratefully appreciated.

 

Thanks,

 

Graeme

 

Inventor 2011 pro

Windows XP Pro 64 SP2

 

 

Regards,
Graeme
3 REPLIES 3
Message 2 of 4
xiaoyan.qi
in reply to: gcooper79

HI, Graeme

 

Here is a Simple VBA code to use if statement for different operation between Part & Assembly

==================================================

Sub SimpleCase()

 

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

 

If oDoc.DocumentType = kPartDocumentObject Then

 ' the statement for Part
ElseIf oDoc.DocumentType = kAssemblyDocumentObject Then

' the statement for Assembly

End If

 
End Sub

==================================================

 

let me know if it works for you

Thanks

Mick

Message 3 of 4
gcooper79
in reply to: xiaoyan.qi

Hi Mick,

 

Thanks for the reply, It worked just as I hoped.  Now that the coding is complete, I would like to make it an Inventor add-in.  The problem is I'm not sure how to achieve this.

 

I'm using visual basic 2010 express, I was following Brian Ekins tutorial "taking the step from VBA to Inventor Add-ins"  but when I  try to debug the project, I get the following message

 

"A project with an output type of class library cannot be started directly. In order to debug this project, add an executable project to this solution which references the libary project. Set the executable project as the startup project."

 

I have searched the Internet for solutions, but the only ones I can find are for use with Visual Studio.

 

Any suggestions?

Regards,
Graeme
Message 4 of 4
xiaoyan.qi
in reply to: gcooper79

in Visual studio, Menu Tools-> Attach to Process, select Inventor Application.

then in Inventor, Load the add-in, work on your Add-in command, if there is error, add breakpoint on the statement to debug it.

 

Hope it's helpful

Thanks

Mick

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

Post to forums  

Autodesk Design & Make Report