Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
sebastian.Flierl7B6DQ
625 Views, 5 Replies

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

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.

 

 

Labels (2)
5 REPLIES 5
Message 2 of 6

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




Message 3 of 6

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)

Message 4 of 6

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.

Message 5 of 6

@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

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.

Post to forums  

Autodesk Design & Make Report