.NET

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

Geometric constraints

391 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

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.

ADN Support Specialist
philippe.leefsma
Posts: 658
Registered: ‎06-02-2009
Message 2 of 3 (308 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 (296 Views)

Re: Geometric constraints

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

Thank you Thank you Thank you!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!