ilogic, prompt select reference dimension to be in existing parameter

ilogic, prompt select reference dimension to be in existing parameter

Smyth_eric
Contributor Contributor
688 Views
4 Replies
Message 1 of 5

ilogic, prompt select reference dimension to be in existing parameter

Smyth_eric
Contributor
Contributor

I am not very good at code, but I am trying to piece together a rule that prompt to link a reference dimension with an already existing custom user parameter by selecting it in the sketch. These parameters are used in the part description. It will have to be a reference dimension because these will be derived parts from a main skeletal model. I have done this with manually typing in the reference dimension names "d45....", just trying to speed up the process.

 

select value for "thickness"

select value for "width"

select value for "length"

 

Im also bummed my rank reset with switching jobs 😞

 

Any help will be greatly appreciated.

 

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

Michael.Navara
Advisor
Advisor
Accepted solution

Try this two examples as starting point

 

Dim targetParmeterName = "Length"
Dim part As PartDocument = ThisDoc.Document
Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select dimension")
Dim dimension As DimensionConstraint = pick
Dim parameterName = dimension.Parameter.Name
part.ComponentDefinition.Parameters(targetParmeterName).Expression = parameterName

 

And one more complex for three dimensions at once

Dim targetParmeterNames As String() = { "Length", "Width", "Thickness" }
Dim part As PartDocument = ThisDoc.Document
For Each targetParmeterName In targetParmeterNames
	Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchDimConstraintFilter, "Select dimension for """ & targetParmeterName & """")
	Dim dimension As DimensionConstraint = pick
	Dim parameterName = dimension.Parameter.Name
	part.ComponentDefinition.Parameters(targetParmeterName).Expression = parameterName
Next
Message 3 of 5

WCrihfield
Mentor
Mentor

Just thinking out loud here, but I'm thinking that if the dimension is a 'reference' dimension, then it must be 'driven' instead of 'driving', and will have a corresponding reference parameter.  Reference parameters are read only, so you won't be able to set their Value or Expression.  Were you intending to just set the name of the reference parameter as the expression/equation of the named user parameter (as in the post above), or did you have something else in mind?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 5

Smyth_eric
Contributor
Contributor

oh man, this is great just what I need. I did find that with the parameters dialog box open you can click in the parameter value and then actually select the dimension in the sketch to link it. but this is much better. 

thanks you.

0 Likes
Message 5 of 5

Smyth_eric
Contributor
Contributor

these parameters are not for controlling anything. I just need the information in my derived parts to report the size in its description. The derived parts are created using geometry from my main controlling sketch.

0 Likes