.NET

Reply
Contributor
insiaiftiqhar
Posts: 19
Registered: ‎06-21-2012
Message 1 of 3 (381 Views)
Accepted Solution

Geometric constraints

381 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..

Thanks

ADN Support Specialist
philippe.leefsma
Posts: 630
Registered: ‎06-02-2009
Message 2 of 3 (298 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:

 

http://forums.autodesk.com/t5/NET/reading-geomeric-constraints/td-p/3714960

 

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(
                goemetry.GeomDependencyId, 
                OpenMode.ForRead) 
                    as AssocGeomDependency;

            Entity entity = Tx.GetObject(
                goemDep.DependentOnObject, 
                OpenMode.ForRead) 
                    as Entity;

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

            return;
        }

        DumpConstrainedGeometry(Tx, goemetry.ConnectedGeometries);
    }
}

 

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

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Contributor
insiaiftiqhar
Posts: 19
Registered: ‎06-21-2012
Message 3 of 3 (286 Views)

Re: Geometric constraints

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

Thank you Thank you Thank you!

Announcements
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 or visit the Installation and Licensing Forum to get help installing your software.