.NET

Reply
Contributor
19 Posts
0 Kudos
Registered: ‎06-21-2012
Post 1 of 3
Accepted Solution

Geometric constraints

398 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
687 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 3

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
19 Posts
0 Kudos
Registered: ‎06-21-2012
Post 3 of 3

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 interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!