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?
Solved! Go to Solution.
Solved by jdkriek. Go to Solution.
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 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.
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.