Autodesk Inventor Customization
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
VBA parameter linking
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello all,
I am about to embark on quite an ambitious project. I would like to write a VBA application (will later convert to plug-in, and ultimately and add-in) to generate the 3D models for a recurring project, but with different input parameters.
My customer builds a product (can't say more about that here), that consists of all manner of Inventor files (i.e. sheet metal parts, normal parts, weldments, sub-assemblies and ultimately a main assembly.
The product has about 12 different "standard" derivatives, but there are subtle changes from one project to the next within these derivatives.
Usually, once the product is modelled, the customer will make small changes that break away from his standard in order to save materials and various other reasons, so changes are inevitable, but they are usually fairly minor and can be controlled by using inventor parameters.
What I would like to do is the following. Using VBA generate a layout file that consists only of the skeletal model, but has all the parameters defining the product as user parameters. From there I want to flesh out and generate the 3D part, sheet metal etc. models by deriving this layout file into the individual parts and then inserting these parts back into the sub assembly files, weldment files and ultimately the final assembly file. I have done the project in this way manually in the past and it seems to be the best option.
At the moment I have a VBA macro written that is the start of the project. So far the macro creates some planes to use as sketch planes.
What I am struggling to figure out right now is; if I have created a plane using VBA macros using the "AddByPlaneAndOffset" method, (I have also created some user parameters), how do I determine the parameter name that is associated with the offset distance of that plane. Once I have this name, I want to edit the expression of that parameter (I think that's how it should be done) so that I can assign one of the user parameters to that model parameter. Ultimately, I would like to be able to "adjust" the position of any of the VBA created planes by changing the user parameters in the layout file.
It may be possible to solve this using iLogic, but somehow I have not had success with iLogic in the past for various reasons.
I have attached the VBA macro as it is at the moment for reference.
I know this is a long winded question / explanation, so thanks for taking the time to read through it.
Rob
-------------------------------------------
Windows 7 Pro (X64)
Intel(R) core (TM) i7-2600 CPU @ 3.40GHz
16.0 GB RAM
Nvidia Quadro 600
Autodesk Inventor 2013 Professional Ultimate Design Suite
Solved! Go to Solution.
Re: VBA parameter linking
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi Rob,
This mod to your code should rename the LAST created paramter (i.e. the Plane Offset). It'll also allow you to the the user parameter as the expression. You'll probably want to pass both of these functions from elsewhere, but it does work.
Just make sure your parameter name does not have any illegal characters in it (spaces, brackets etc.)
Hope this is what you were looking for - I got a bit lost in your question!
Cheers
Jon.
Private Sub CreatePlane(refPlane As String, planeName As String, offset As Double, oDoc As PartDocument)
Dim oWorkPlane As WorkPlane
Set oWorkPlane = oDoc.ComponentDefinition.WorkPlanes.AddByPlaneAndO
oWorkPlane.Name = planeName
Dim oCompDef As PartComponentDefinition
Set oCompDef = oDoc.ComponentDefinition
Dim oParams As Parameters
Set oParams = oCompDef.Parameters
Dim oModelParams As ModelParameters
Set oModelParams = oParams.ModelParameters
Dim oModelParam As ModelParameter
Set oModelParam = oModelParams.Item(oModelParams.Count)
oModelParam.Expression = "=VARM002" '
oModelParam.Name = "GoatsCheese"
End Sub
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Re: VBA parameter linking
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello Jon,
What you have suggested will work for me thanks.
Regards
Rob
Rob
-------------------------------------------
Windows 7 Pro (X64)
Intel(R) core (TM) i7-2600 CPU @ 3.40GHz
16.0 GB RAM
Nvidia Quadro 600
Autodesk Inventor 2013 Professional Ultimate Design Suite
