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: 

Number of Constraints Needed to fully constrain a sketch

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
davidm
931 Views, 5 Replies

Number of Constraints Needed to fully constrain a sketch

Hello all,

 

When you're working on a sketch in the part environment the status bar shows the number of constraints needed to fully constrain the sketch.  For example "2 Dimensions Needed".

 

How do you retrieve this value using Visual Basic Net?

 

5 REPLIES 5
Message 2 of 6
jdkriek
in reply to: davidm

The Sketch object has ConstraintStatus that will report whether the sketch is fully constrained, over constrained, or under constrained, but I do not think it's possible to query how many constraints are required via the API - despite the readout in the status bar. You can also write things to the status bar, but I am not aware of methods to extract the values from the status bar.

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 6
davidm
in reply to: jdkriek

Thanks for the reply jdkriek, but as you said the information is there.
There must be a way to extract it.



I'm hoping that someone from the Autodesk development team can help me with
this one.



Thanks again.
Message 4 of 6
ekinsb
in reply to: davidm

Jonathan is correct.  The number of dimensions/constraints needed to fully constrain the sketch is not available through the API.  You're also correct that Inventor knows the number but without it being exposed through the API there isn't any access to that information.  The only potential workaround I can envision would be to write some Windows API code that tries to extract the text from the status bar.  This would be messy and would also require that the sketch be active.  If you want to pursue this, Google can be a big help on finding code.  I don't have any samples to give you a head start.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 6
davidm
in reply to: ekinsb

Thanks for confirming Jonathan's input. I had a feeling it wasn't exposed
though the API, but it just seems like it should be.



I'm trying to determine if a sketch is fully constrained or
under-constrained, but the ConstraintStatus does not return accurate
information. Sketches created from a surface return 51716, which is the
unknown constraint status, and I've experienced it returning 51713
kFullyConstrainedStatus when the sketch is actually under constrained. To
get this result I created a sketch on a rectangular surface and then draw a
circle on it and added a diametral dimension. The center of the circle was
not constrained and the status bar showed 2 dimensions needed.
ConstraintStatus returned kFullyConstrainedConstraintStatus 51713.



I've also tried _GeometryMoveableStatus on all the entities in the sketch
and found it to be inconsistent as well. By hunt and peck I figured out
that a movable sketch entity returns 53505, at least I think this means it's
movable. This worked better than ConstraintStatus, but did not produce
consistent results. A fully constrained sketch that I tested showed that
some of the entities in the sketch were movable or at least they returned
53505. As I said, I'm guessing that 53505 means it's moveable.



The only accurate information about the constraint status of a sketch is in
the status bar, which is why I asked about it. If you have any comments
about my statement above please let me know. In the mean time I'm going to
take your suggestion and Google the status bar text code.



Best regards,

David
Message 6 of 6
ekinsb
in reply to: davidm

Looks like there may be a problem that needs to be investigated.

 

There is one thing with entities being "fully constrained" that's not very intuitive and may explain some of the behavior you're seeing.  You can see this when working with Inventor interactively.  If you create a new sketch and draw a horizontal line.  The line will be green indicating it's not fully constrained.  Now add a Fix constraint to one end of the line. The line will change colors indicating it's fully constrained, but it's not because the length is still undefined. The status bar is correct and indicates that one more dimension is needed.  The ConstraintStatus property on each sketch entity is reporting the same information that's used to color the entity.

 

I'm not arguing that this is the desired behavior but just explaining the current behavior.  In this case, the line is treated as an infinite line.  The horizontal constraint and fixing one of it's end points does fully constrain the line if you consider it to be an infinite line.  The sketch consists of three entities, the line and two sketch points (one at each end of the line).  If you check the ConstraintStatus property it will tell you that one point is fully constrained, the line is fully constrained, but the other point is underconstrained.  It's the second point that controls the length of the line.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report