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
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.
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
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.
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.
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
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.