.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Geometric constraints

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
insiaiftiqhar
917 Views, 2 Replies

Geometric constraints

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

2 REPLIES 2
Message 2 of 3

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

Message 3 of 3

Thank you Thank you Thank you!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost