C#/FB.net: Using/Reading Constraint Limits

C#/FB.net: Using/Reading Constraint Limits

sebastian.Flierl7B6DQ
Explorer Explorer
847 Views
5 Replies
Message 1 of 6

C#/FB.net: Using/Reading Constraint Limits

sebastian.Flierl7B6DQ
Explorer
Explorer

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)

 

ReadingConstraintLimist C#.PNG

 

 

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.

 

 

0 Likes
Accepted solutions (3)
848 Views
5 Replies
Replies (5)
Message 2 of 6

laszlo_nagy
Contributor
Contributor
Accepted 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




0 Likes
Message 3 of 6

laszlo_nagy
Contributor
Contributor
Accepted solution

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)

0 Likes
Message 4 of 6

sebastian.Flierl7B6DQ
Explorer
Explorer

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.

0 Likes
Message 5 of 6

dutt.thakar
Collaborator
Collaborator
Accepted solution

@sebastian.Flierl7B6DQ 

 

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.

 

ConstraintLimit.PNG

 

Hope this will help you.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn
Message 6 of 6

sebastian.Flierl7B6DQ
Explorer
Explorer

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.

0 Likes