inventor vba user parameter

inventor vba user parameter

Anonymous
Not applicable
1,876 Views
7 Replies
Message 1 of 8

inventor vba user parameter

Anonymous
Not applicable

Hello everyone,

I was trying to put together a vba for inventor that would let user browse for excel file with three columns; column A for name of parameter, B will be value and C units. Then vba will loop through the excel get the parameter name and see if it exist in the inventor file, if so it will just get the value and unit ,if not it will create the user parameter. So far I got the vba to browse for the file and open and after that I couldn’t figure out how to do the loop. when i run the vba it let me pick the excel file then it will freeze. With the help of this forum I have an ilogic rule that does it but I am trying to have the vba version of it. i have attached the vba i have as  a text. sample vba or guidance will be appreciated. Thank you very much.

0 Likes
1,877 Views
7 Replies
Replies (7)
Message 2 of 8

NachoShaw
Advisor
Advisor
Hi

You could do the following (no coding supplied)

Open excel
County how many rows have data
Get the row count and do a loop

For I =0 to RowCount
Get each value and check with Inventor
Next I

I've never been a fan of Do While

FYI

Your inventor code opens a connection each loop. That could be a lot of memory. You would be better with a routine that

Makes a single connection to the doc and keep it
Store the connection as a variable
Move the code for inventor to a function
Call the function passing the active doc
Do your looping
Close the connection.

An example:

Sub GetParams ()

'Make your excel connection here
'Loop your parameters here

'Row Count = amount of rows with data

Dim oDoc As Document
Set oDoc As ThisApplication.ActiveDocument

For i = 0 to RowCount
ParamName = Row.Value

Call CheckParams (ParamName, oDoc)

oDoc.Close
oDoc = Nothing

End Sub

Function CheckParams (ParamName As String, doc As Inventor.Document)

'Do your inventor work here using ParamName & Doc

End Function

This is one connection to excel, one connection to the Inventor Document.

If you struggle, give me a shout and i'll rustle something up


Nacho


Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 3 of 8

Anonymous
Not applicable

Nacho,

Thank you for taking the time to help me out. Sorry I forgot to mention it but I am completely new to vba and so far my experience have been to get codes from forums/help file then modify them to fit my need. I did try to build upon the example you provided me but I couldn’t get anywhere after researching for a while. Attached is what I did based on your suggestion not sure if I even did that right, could you build upon it when you get the chance.

 

Sincerely,

 

Adam t.   

0 Likes
Message 4 of 8

NachoShaw
Advisor
Advisor

no probs mate,

 

i'll take a look tomorrow (Friday)

 

cheers

 

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Message 5 of 8

NachoShaw
Advisor
Advisor
Hey man

Sorry I got occupied elsewhere. If you want to send me your project / file / workbook, I'll sort it out tomorrow

Cheers

Nacho

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 6 of 8

NachoShaw
Advisor
Advisor
Email nmjshaw at Outlook dot com

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes
Message 7 of 8

Anonymous
Not applicable

Just sent you an email. Thanks.

0 Likes
Message 8 of 8

NachoShaw
Advisor
Advisor

got it mate, will look at it later

 

cheers

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


0 Likes