Parameter("Part Name.ipt", "ParamName") API equivalent

Parameter("Part Name.ipt", "ParamName") API equivalent

johnster100
Collaborator Collaborator
529 Views
2 Replies
Message 1 of 3

Parameter("Part Name.ipt", "ParamName") API equivalent

johnster100
Collaborator
Collaborator

Hi There,

over the years I have written quite a lot of code in iLogic. I am now writing some in vb.net so I can take advantage of the debugging in visual studio.

 

An illogic expression I often use is:

 

x = Parameter("Part Name.ipt", "ParamName")  

 

to retrieve a value from a part which is linked.

 

I am looking for a method to do this in vb.net using API code.

 

Could someone help me please?

 

I've attached a simple file with the ilogic which maybe explains my situation better. In the example the illogic code is in the assembly file and reads a parameter from part1 which is linked to part2.

 

thanks,

John

0 Likes
Accepted solutions (1)
530 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor
Accepted solution

Something along these lines should work.

 

Note that parameter.value by itself returns the value in parameter units (cm) and not the specified units. This function has the conversion back built in. However, I have not tried debugging this snippet, so it may not work first go around.

 

 

' Custom Parameter("Part Name.ipt", "ParamName") replacement

Function GetParameter(oPartName, oParamName) As String
   On Error Resume Next
 
   For Each oDoc in ThisApplication.Documents
       If oDoc.FullFileName Like "*" & oPartName Then
           Exit For
       End if
    Next

oUOM = oDoc.UnitsOfMeasure
oParam = oDoc.ComponentDefinition.Parameters.Item(oParamName)
oParamUnits = oParam.Units
oParamVal = oParam.Value

oParamVal = oUOM.ConvertUnits(oParamVal, "in", oParam.Units)
Return oParamVal End Function

 


--------------------------------------
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 3 of 3

johnster100
Collaborator
Collaborator

Thanks, that worked perfectly 🙂

0 Likes