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

reading geomeric constraints

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

reading geomeric constraints

How do you read geometric constraints from the Assoc2dConstraintGroup in C# or VB?

2 REPLIES 2
Message 2 of 3

Hi There,

 

Here is a c# sample that illustrates how to get started:

 

[CommandMethod("DumpConstraints")]
public void DumpConstraints()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    ObjectId networkId = AssocNetwork.GetInstanceFromObject(
        db.CurrentSpaceId, 
        false, 
        true, 
        "ACAD_ASSOCNETWORK");

    if (networkId == ObjectId.Null)
        return;

    using (Transaction Tx = 
        db.TransactionManager.StartTransaction())
    {
        using (AssocNetwork network = 
            Tx.GetObject(
                networkId, 
                OpenMode.ForRead, false) as AssocNetwork)
        {
            foreach (ObjectId actionId in network.GetActions)
            {
                if (actionId == ObjectId.Null)
                    continue;

                DBObject obj = Tx.GetObject(
                    actionId, 
                    OpenMode.ForRead);

                //ed.WriteMessage("\n - Action: " + obj.ToString().Remove(0, 34));

                if (actionId.ObjectClass.IsDerivedFrom(
                    RXObject.GetClass(
                        typeof(Assoc2dConstraintGroup))))
                {
                    Assoc2dConstraintGroup group = obj 
                        as Assoc2dConstraintGroup;

                    foreach(GeometricalConstraint constraint 
                        in group.Constraints)
                    {
                        //... do something ...
                    }
                }
            }
        }
    }
}

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

I can't thank you enough for helping me. I had given up and was working on an alternate/not so elegant solution. Thank you SO very much!

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