User Parameter: How to retrieve Dimension Text Box Text

User Parameter: How to retrieve Dimension Text Box Text

RoyWickrama_RWEI
Advisor Advisor
779 Views
4 Replies
Message 1 of 5

User Parameter: How to retrieve Dimension Text Box Text

RoyWickrama_RWEI
Advisor
Advisor

I need to retrieve the user parameter text box information with an iLogic code.

Please see below (sample ipt added):

User para.pngI Request someone help me.

Also, how can I distinguish a model parameter from a user parameter?

Note: Currently, I manually type in the user-parameter name. (In this regard, the selected dimension need not to be the parameter I type in).

Thanks.

 

0 Likes
Accepted solutions (1)
780 Views
4 Replies
Replies (4)
Message 2 of 5

RodrigoEiras
Advocate
Advocate

Hello,

 

 

I think you can get the parameter name from the dimension using: parameter.Expression

 

Something like this:

 

SyntaxEditor Code Snippet

Dim p As Parameter

p = Parameter.Param("d0")
trace.writeline(p.Expression)

  

I hope it helps.

 

 

 

 

Message 3 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@RoyWickrama_RWEI,

 

Hoping that below iLogic code would help to get user parameter name of selected dimension.

 

Sub Main()
	Dim oSelectedDim As DimensionConstraint
	oSelectedDim = ThisApplication.Commandmanager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter,"Select a dimension to change dimension")
    
    If oSelectedDim.Parameter.DrivenBy.Count > 0 Then
        Dim oUserParam As UserParameter
        oUserParam = oSelectedDim.Parameter.DrivenBy.Item(1)
		
	MsgBox ("User parameter name is '" & oUserParam.Name & "'") 
        
    Else
        MsgBox ("Selected dimension is not contianing any user parameter")
    End If

	iLogicVb.UpdateWhenDone = True
End Sub

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 4 of 5

RoyWickrama_RWEI
Advisor
Advisor

Hi Chandra Shekar Gopal;

 

Great piece of code and GREAT HELP. I am getting what I need to do.

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument
Dim oParameter As Parameter
	Dim oSelectedDim As DimensionConstraint
	oSelectedDim = ThisApplication.Commandmanager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter,"Select a dimension to change dimension")
    
    If oSelectedDim.Parameter.DrivenBy.Count > 0 Then
        Dim oUserParam As UserParameter
        oUserParam = oSelectedDim.Parameter.DrivenBy.Item(1)
		
'	MsgBox ("User parameter name is '" & oUserParam.Name & "'") 
	oText = ""
	x = 0
	100:
	If x >0 Then oText = "HIT OK BUTTON"
	oUP_Edit_X = InputBox("REVISE USER PARAMETER: " _
	& vbLf & "" _
	& vbLf & oText, "PARAMETER NAME", oUserParam.Name)
	If oUP_Edit_X = "" Then 
	x += 1
	Goto 100:
	End If
	
	On Error Resume Next
	Parameter(oUP_Edit_X) = InputBox("Current Value", "USER PARAMETER EDIT: " & oUP_Edit_X, Parameter(oUP_Edit_X))	
	Else
        MsgBox ("Selected dimension is not contianing any user parameter")
    End If
	iLogicVb.UpdateWhenDone = True
End Sub

 

 

 

0 Likes
Message 5 of 5

RoyWickrama_RWEI
Advisor
Advisor

Thanks for the reply.

I have not so far done any thing using:

trace.writeline(p.Expression)

I shall be most grateful in case you provide me with a complete code for using the above. 

0 Likes