Posts: 19
Registered: ‎06-21-2012
Message 1 of 3 (373 Views)
Accepted Solution

Geometric constraints

373 Views, 2 Replies
11-16-2012 02:38 PM

In a given drawing I want to list pairs of blocks that are constrained to each other by "coincidence constraint" .

For example, I have a simple drawing with a rectangle block and a line block . I applied coincidence constraint to the end of the line and midpoint of one edge of the rectangle block

I get the Assoc2dConstraintGroup  object for the drawing  and I can see the constraints array for this object in the watch window. It has one midpoint constraint , one point coincidence constraint and 5 point curve constraints. I think I need to explore the point coincidence constraint, but I am not sure. How can I extract the information I am looking for? I see variables like connected geometries and connected constraints but I am not able to tie them together to derive what I want.
 also Is there a MSDN/ javadocs style API browser for AutoCAD. net? that would be a HUGE help..


ADN Support Specialist
Posts: 576
Registered: ‎06-02-2009
Message 2 of 3 (290 Views)

Re: Geometric constraints

12-04-2012 01:17 AM in reply to: insiaiftiqhar

Hi There,


You can refer to the following post that illustrates how to iterate through the constraints:




Once you have access to a GeometricalConstraint object, you can use its "ConnectedGeometries" property to deduce on which entity is applied the constraint:


void DumpConstrainedGeometry(
    Transaction Tx, 
    ConstrainedGeometry[] geometries)
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Editor ed = doc.Editor;

    foreach (ConstrainedGeometry goemetry in geometries)
        ed.WriteMessage("\n  - Constrained Geometry: " + 
            goemetry.ToString().Remove(0, 34));

        if(goemetry.GeomDependencyId != ObjectId.Null)
            AssocGeomDependency goemDep = Tx.GetObject(
                    as AssocGeomDependency;

            Entity entity = Tx.GetObject(
                    as Entity;

            ed.WriteMessage(" with Constrained Entity: " + 
                entity.ToString().Remove(0, 34));


        DumpConstrainedGeometry(Tx, goemetry.ConnectedGeometries);


Concerning the doc question, there is a chm help file coming with the ObjectARX SDK that is quite helpful.




Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Posts: 19
Registered: ‎06-21-2012
Message 3 of 3 (278 Views)

Re: Geometric constraints

12-04-2012 12:35 PM in reply to: philippe.leefsma

Thank you Thank you Thank you!

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community