How to access part parameter in an assembly using VB.net

How to access part parameter in an assembly using VB.net

bwang-tecoustics
Collaborator Collaborator
1,820 Views
5 Replies
Message 1 of 6

How to access part parameter in an assembly using VB.net

bwang-tecoustics
Collaborator
Collaborator

iLogic use:

Parameter("Part1:1", "d0")

But how to do this in VB.net? The part1 is in a assembly and I want to change a parameter in the part.

 

0 Likes
Accepted solutions (2)
1,821 Views
5 Replies
Replies (5)
Message 2 of 6

tolgay.hickiran
Advisor
Advisor
http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-E2988B34-C0A9-49F8-993B-A9DB6EFD8EE9

here's the help document you need. This is also located in your Inventor aswell.

Some worthwhile ideas
Copy Design should rename ilogic Rules too!
Why Nastran In-CAD doesn't have an SDK?IMPLEMENTED!

Tolgay Hickiran
Founding Partner
SignatureSignature

website
emailskypelinkedinyoutubeemail

Message 3 of 6

bwang-tecoustics
Collaborator
Collaborator

Thx. I was able to use the code below to access the UserParameter in the assembly. As the oOcc is the ComponentOccurence of the part, and its Parent is the assembly file. But what I'm trying to do is to change the value of the UserParameter in the part file, which is the oOcc itself.

oParas = oOcc.Parent.Parameters.UserParameters

The other question is the UserParameter.Value is an object per the help file. what should I do to change it's really value? Does Inventor treat the dimensions like "2 in" or "30 mm" as object?

0 Likes
Message 4 of 6

bwang-tecoustics
Collaborator
Collaborator
Accepted solution

Finally, I could use the following code to modify the UserParameters in the part file.

oOcc.Edit() 'Edit the part file in the assembly
                        Dim oPDoc As Inventor.Document
                        oPDoc = _invApp.ActiveEditDocument

                        Dim allParams As Parameters = oPDoc.ComponentDefinition.Parameters
                        oParas = allParams.UserParameters

oOcc.ExitEdit(ExitTypeEnum.kExitToParent) 'Exist editing after finish
0 Likes
Message 5 of 6

MechMachineMan
Advisor
Advisor
Accepted solution

If you already have the occurrence, the better method is this:

 

oUserParams = oOcc.Definition.Parameters.UserParameters

Editting the document first is cumbersome and much more resource intensive.

 

You can find this all in the API help....

 

%Public Documents%\Autodesk\Inventor 2017\Local Help\ad_mapi....chm


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 6 of 6

bwang-tecoustics
Collaborator
Collaborator

Thanks. This is better.

0 Likes