I would like to read the Value of ConstraintLimits.MaximumEnabled by using the API with a C# Code. (using visual Studio). I don´t get access to the ConstraintLimits by Using a C# Code. (same with FB.net). There is a difference to the VBA script.
If I use a VBA script i can do this with the following code:
Dim MaximumEnabled As bool
MaximumEnabled = oOcc.Definition.Occurrences.Constraints.ConstraintLimits.MaximumEnabled = True
If I use a C# script there is a Property "ConstraintLimits" for my Constraints but I don´t habe acess to it. (see.Figure)
How can I use the ConstraintLimits with a C# Code?
What is the difference between C# and VBA in this case?
Using Autodesk Inventor Professional 2021 and Visual Studio 2019.
Hope someone can help me.
Thanks a lot.
Solved! Go to Solution.
Solved by dutt.thakar. Go to Solution.
Solved by laszlo.nagy. Go to Solution.
Solved by laszlo.nagy. Go to Solution.
I think "AssemblyConstraint" Object doesn't have this property ("ConstraintLimits")
https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-BF70CF3D-0631-44FE-B31B-21E380F067FE
Only specified Constraint Objects have this property
https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-F568FC0E-6CE0-4408-9713-091E7E9E8EDA
see the "Accessed From" List
In VB you can do this way ( I don't know C#)
For each obj in oTempOcc.Constraints
bMaximumEnabled = obj.ConstraintLimits.MaximumEnabled
next obj
(or you have to declare specific variable, with the right type)
Thank you for your answer.
I have to declare the variable with the right type in C#.
So if I understand correct, i have to do it like this:
1. Identify the type of the Assembly Constraint (AngleConstraint e.g.)
2. Then I can use a variable with the right type (AngleConstraint) to get acess to the ConstraintLimits.
I will try this and give you a feedback.
I think you need to be quite specific with constraints here, See the below snapshot where I have tested with a Flush constraint in C# and Inventor 2021, I am able to access the property and also able to read the value as well.
Hope this will help you.
Thank you both for your answers. This really helped me.
Now i use a dynamic variable to avoid the differetiation of the specific constraints typs.
Can't find what you're looking for? Ask the community or share your knowledge.