Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inventor Parameters

15 REPLIES 15
Reply
Message 1 of 16
dlegan
976 Views, 15 Replies

Inventor Parameters

Hello all.

 

Not long ago, I built a 3d model in inventor and used vba to change the parameters. I had a form with text boxes to enter the values then update the model. I had the code to attach the parameters to the values but have since lost this. Is anyone familiar with this code or where to find a tutorial?

 

Thanks, David

 

15 REPLIES 15
Message 2 of 16
danzco
in reply to: dlegan

David,

 

I would recommend that you take a look at iLogic.  Syntactically it is VBA, but AutoDesk has integrated it into Inventor for you.

Message 3 of 16
dlegan
in reply to: dlegan

Thank you for the response. I guess what I need to find most is how to attach the parameter value to the text box value in code. I thought this was easy to find before but haven't had any luck. Will keep looking and thank you again.

Message 4 of 16
danzco
in reply to: dlegan

Can you be any more specific about your use case?

Message 5 of 16
dlegan
in reply to: dlegan

I'll try

 

To be simple,say a 3d mode with width,height,and thickness.

 

I want the vb code to attach the parameters to a variable that can be used a a text input box

 

such as

 

 Dim heightParam as Parameter

 

height Param = txtHeight.text

 

Then up date the mpdel

 

There was a function I found once to do this,just can't find it now

 

 

Again,thanks for your help

Message 6 of 16
danzco
in reply to: dlegan

Like this? (See attached file)

Message 7 of 16
dlegan
in reply to: dlegan

Yes, just one question. Where is the code. Wouldn't it be in the vba editor?

 

Thanks

 

Message 8 of 16
danzco
in reply to: dlegan

There is very little actual code. To look at how I built that, go to Manage tab -> iLogic pane -> iLogic Browser.  There is one Rule and one Form.  The rule simply displays the form when the document is opened, while the form allows you to change the dimension parameters of the model.  Right clicking on the "Dimensions" button will allow you to see the guts.

 

To set something like that up, model the part first.  On the forms tab of the iLogic browser you can then right click on the white space and make a new form.  Just drag the parameters from the bar on the left into the workspace.  To make the form display on document open I made that simple rule that shows the form, then assigned that rule to run when the document is opened via the Event Triggers dialog on the iLogic pane.

 

Good luck!

 

Please mark this post a solution if this answers your question.

Message 9 of 16
mrattray
in reply to: danzco

Not that there's anything wrong with danzco's example, but here's another example of something a little more complicated in case you waned to see an example where iLogic (VBA) comes into play.

Mike (not Matt) Rattray

Message 10 of 16
dlegan
in reply to: dlegan

I can't figure out anything with this. Wish I had a place for just some vba code.

 

 

Thanks for your help again.

Message 11 of 16
mrattray
in reply to: dlegan

You do.

1) Create an iLogic rule

2) Type or paste your VBA code

Mike (not Matt) Rattray

Message 12 of 16
danzco
in reply to: mrattray

If you want the traditional VBA window you can access it by pressing Alt+F11

Message 13 of 16
dlegan
in reply to: mrattray

Thanks again for your help

 

Can you look at this and tell me something?

 

Dim oParameters As Parameters

 Set oParameters = ThisApplication.ActiveDocument.ComponentDefinition.Parameters.Item("Length")

 

In the code, the "ComponentDefinition" is not recognized, is this a reference issue?

 

Thanks again

 

 

Message 14 of 16
mrattray
in reply to: dlegan

You need to create a variable and assign it a document type and give it a value of thisapplication.activedocument. Then you can access component definition on it. Although, I don't think parameters is a member of component definition anyways.

 

If you are in iLogic you can reference parameters directly (i.e. Length = 5). This is by far the easiest environment to code in. Unless you have to for some reason you should be using iLogic.

 

If you insist on working in the API then here is an example of how to reference parameters using straight VBA. This example adds a text parameter called text0 and assings it a value of From Automation:

Dim iLogicAuto As Object
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub

Dim curDoc As Document
Set curDoc = ThisApplication.ActiveDocument

iLogicAuto.paramvalue(curDoc, "text0") = "From Automation"

 

Again, just use iLogic. It's a lot easier.

Mike (not Matt) Rattray

Message 15 of 16
dlegan
in reply to: dlegan

Hello again. Does anyone know a good reference for C# programming with inventor parameters?

 

Thanks

Message 16 of 16
jletcher
in reply to: dlegan

I would suggest looking into ilogic this is the way Inventor will be going....

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

Post to forums  

Autodesk Design & Make Report