Add user text parameter through iLogic

Add user text parameter through iLogic

Anonymous
Not applicable
3,232 Views
6 Replies
Message 1 of 7

Add user text parameter through iLogic

Anonymous
Not applicable

Using Inventor 16

 

I am trying to add a user text parameter to the active document (typically ipt) with the following in an iLogic rule:

oUParams=ThisApplication.ActiveDocument.ComponentDefinition.Parameters.UserParameters
oUParams.AddByValue ("Description","",UnitsTypeEnum.kTextUnits)

Running this doesn't throw any errors, but it also doesn't create the parameter.

 

What am I doing wrong?

 

0 Likes
3,233 Views
6 Replies
Replies (6)
Message 2 of 7

MechMachineMan
Advisor
Advisor

Works fine for me.

 

Please ensure that you don't have any filters applied in your parameters dialog.


--------------------------------------
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
0 Likes
Message 3 of 7

gavin.allenHSSRX
Enthusiast
Enthusiast

This does not work for me either.  Is there some coding before or after we should be using?

K.I.S.S. (keep it simple stupid)
Life doesn't have to be complicated.
Designs don't have to be complicated.
GOD Bless you.
0 Likes
Message 4 of 7

MechMachineMan
Advisor
Advisor

I tried it again, and copy/pasting that code adds the parameter just fine.

 

Perhaps it wouldn't if the part wasn't a library file, or unmodifiable otherwise?

 

Try adding the user parameter manually through the UI. Does that work?

 

Secondly, can you verify that you don't have an parameter filters on?

 

Thirdly, you are running the parameter from the ACTIVE document and not during an "in-place edit"?

 

If you want it to work even during in-place editting, it should be written:

 

oUParams=ThisDoc.Document.ComponentDefinition.Parameters.UserParameters
oUParams.AddByValue ("Description","",UnitsTypeEnum.kTextUnits)

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

bradeneuropeArthur
Mentor
Mentor

This works for me:

 

    Private Sub Button25_Click(sender As Object, e As EventArgs) Handles Button25.Click
        Dim oDoc As Document
        oDoc = _InvApp.ActiveDocument

        'On Error GoTo noPartOrAss:
        Dim oParameters As Parameters
        oParameters = oDoc.ComponentDefinition.Parameters

        Dim oParameterTables As ParameterTables
        oParameterTables = oParameters.ParameterTables
        'Debug.Print oParameters.ParameterTables.Count

        Dim oParameterTable As ParameterTable
        oParameterTable = oParameterTables.Item(1)

        Dim oUserParameters As UserParameters
        oUserParameters = oParameters.UserParameters

        Dim oTableParameters As TableParameters
        oTableParameters = oParameterTable.TableParameters


        Dim UserParameterAdd As UserParameter
        UserParameterAdd = oUserParameters.AddByValue("Test" & "_UPT", "AA", UnitsTypeEnum.kTextUnits)
    End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 6 of 7

gavin.allenHSSRX
Enthusiast
Enthusiast

Bless You Justin,

 

I was trying to do it thru the in place edit.  Thanks so much for the edification.

 

 

K.I.S.S. (keep it simple stupid)
Life doesn't have to be complicated.
Designs don't have to be complicated.
GOD Bless you.
0 Likes
Message 7 of 7

MechMachineMan
Advisor
Advisor

If that has it solved, please mark the answer as a solution!


--------------------------------------
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
0 Likes