Create constraint with "value" ( Parameter and/or Math Syntax, etc )

Create constraint with "value" ( Parameter and/or Math Syntax, etc )

Crstiano
Collaborator Collaborator
674 Views
3 Replies
Message 1 of 4

Create constraint with "value" ( Parameter and/or Math Syntax, etc )

Crstiano
Collaborator
Collaborator
Components.Add("MyNewComponent", MyFile.ipt)	
Constraints.AddFlush("Flush:1", "MyNewComponent", "XY Plane", "", "XY Plane", Distance) 

 

There are a function that simulate the same routine that the inventor does a textbox for enter distance value ?

Or verify is there are parameter, or is a math syntax, or both..

Or someone writed all these checks and can do share this code?

I accept suggestions.

 

Thanks in advance

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Cristiano Oliveira
EESignature
ConsultCAD.com

0 Likes
675 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Are you asking about this function?

Dim oDistance As Double = InputBox("Enter Distance.")

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Crstiano
Collaborator
Collaborator

Maybe I'm created a tempest in a teapot...

 

The question is about: How to create a textbox at form equal (with all features includes) like the autodesk inventor ?

example: the offset at constraint, where its check if the value is: parameter , a syntax math, or if you specify which units etc...

 

 

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


Cristiano Oliveira
EESignature
ConsultCAD.com

0 Likes
Message 4 of 4

JhoelForshav
Mentor
Mentor

Hi @Crstiano 

What you write in the textbox for distance is actually a parameter expression.

You can use UnitsOfMeasure to evaluate if an expression is valid. See iLogic code below. In the example I let the user type in an expression. It can contain names of parameters in the document, math signs etc. If its a valid length the code will return the calculated length in a msgbox, else it'll tell you the expression isn't valid.

 

Dim oUOM As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure
Dim otext As String = InputBox("Length expression: ", "write expression")
Dim oValidEx As Boolean
Try
oValidEx = oUOM.CompatibleUnits(otext, UnitsTypeEnum.kDefaultDisplayLengthUnits, "1", UnitsTypeEnum.kDefaultDisplayLengthUnits)
Catch
oValidEx = False
End Try
If oValidEx
	Dim oValue As Double = oUOM.GetValueFromExpression(otext, UnitsTypeEnum.kDefaultDisplayLengthUnits)
	Dim oValueString As String = oUOM.GetStringFromValue(oValue, UnitsTypeEnum.kDefaultDisplayLengthUnits)
	MsgBox("Return length: " & oValueString)
Else
	MsgBox("Not valid length expression")
End If

 

Check page 21 here for the textbox you describe 🙂

https://modthemachine.typepad.com/files/ipropertiesandparameters.pdf