While in nested transactions, the door/window which is anchored to the wall does not move when the wall moves

While in nested transactions, the door/window which is anchored to the wall does not move when the wall moves

ptranU2KHX
Advocate Advocate
629 Views
7 Replies
Message 1 of 8

While in nested transactions, the door/window which is anchored to the wall does not move when the wall moves

ptranU2KHX
Advocate
Advocate

Hi everyone

 

In Autocad Architecture, door/window has feature to be anchored with a wall. Whenever the wall moves, the anchored objects will be moved accordingly.

 

However, when I am in the middle of the nested transactions, either using API or manually moving wall will not move the door/window.

 

ptranU2KHX_0-1695635610300.png

 

I'd like to describe a little bit about my nested transactions. I have a TrGroup transaction, which is started at the beginning of the process and is disposed when the user close the form. Whenever the user hits a button, there will be another transaction executed. This transaction is supposed to be inside the TrGroup transaction as the TrGroup is not disposed of yet.

 

Thanks in advance.

0 Likes
630 Views
7 Replies
Replies (7)
Message 2 of 8

Gepaha
Collaborator
Collaborator

What command are you using to move the wall?
I could be wrong but I think this only works if you use the traditional move command (native commands).
I think that if you use .NET API you are responsible for implementing the code for moving doors and windows together.
Could you post the code that implements the wall displacement?

Message 3 of 8

ptranU2KHX
Advocate
Advocate

Thank you @Gepaha for reading the post.

 

I use 'TransformBy(transform As Matrix3d)' method. Besides, as mentioned previously, I already tried to use the traditional move command (native commands) but it did not work either when the outermost transaction is not committed.

0 Likes
Message 4 of 8

Gepaha
Collaborator
Collaborator

If you are using TransformBy to move the wall then you will also have to do the same process with the openings (doors, windows, etc.).
I did a quick test here with doors and windows (I didn't take Body Modifier or other unforeseen circumstances into consideration), apparently it's working correctly.

If you move the wall you will also have to take into consideration whether there is a tag anchored to it, I haven't implemented this here but I think it's easy.

 

 

[CommandMethod("MoveWallTest")]
public void MoveWallTest()
{
  Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
  Database db = HostApplicationServices.WorkingDatabase;
  PromptEntityOptions optEnt = new PromptEntityOptions("\nSelect a wall: ");
  optEnt.SetRejectMessage("\nSelected entity is Not a wall.\n");
  optEnt.AddAllowedClass(typeof(Wall), true);
  PromptEntityResult resEnt = ed.GetEntity(optEnt);
  if (resEnt.Status != PromptStatus.OK)
     return;
  AcDb.ObjectId wallId = resEnt.ObjectId;

  PromptPointResult ppr;
  PromptPointOptions ppo = new PromptPointOptions("\nReference point: ");
  ppr = ed.GetPoint(ppo);
  if (ppr.Status != PromptStatus.OK)
     return;
  Point3d refPoint = ppr.Value;

  ppo.Message = "\nNext point: ";
  ppo.UseBasePoint = true;
  ppo.BasePoint = refPoint;
  ppr = ed.GetPoint(ppo);
  if (ppr.Status != PromptStatus.OK)
     return;
  Point3d nextpoint = ppr.Value;
  Vector3d displacementVector = refPoint.GetVectorTo(nextpoint);           

  using (Transaction trans = db.TransactionManager.StartTransaction())
  {
     try
     {
        Wall wall = trans.GetObject(wallId, OpenMode.ForWrite) as Wall;
        AcDb.ObjectIdCollection openingsIdc = wall.GetOpeningsFor();
        wall.TransformBy(Matrix3d.Displacement(displacementVector));
        foreach (AcDb.ObjectId id in openingsIdc)
        {                       
          Opening opening = trans.GetObject(id, OpenMode.ForWrite) as Opening;
          if (opening != null)
          {
             opening.TransformBy(Matrix3d.Displacement(displacementVector));
          }
       }                   
    }
    catch (System.Exception ex)
    {
       Application.ShowAlertDialog(ex.GetBaseException().ToString());
    }
    trans.Commit();
  }
}

 

 

Message 5 of 8

artc2
Autodesk
Autodesk
When a nested transaction is closed, the objects that were opened into that transaction are not closed, they are simply moved to the next outer transaction. So, until the outermost transaction is ended, the objects that were opened in any nested transactions are still open until the outermost transaction is ended.

Think of nested transactions as undo markers that allow undoing to that marker because that's essentially what they are.
Message 6 of 8

ptranU2KHX
Advocate
Advocate

Thank @Gepaha 

 

The problem is in Autocad Architecture, the door/window has a property 'anchor' so that when the wall moves, the anchored door/window will move accordingly.

So in my logic, I will ignore the door/wall. What I move is the only wall and somehow in the nested transaction, the door/window seems stuck at their original location.

 

ptranU2KHX_0-1695777836435.png

 

0 Likes
Message 7 of 8

ptranU2KHX
Advocate
Advocate

Thank @artc2 . I get your point here.

 

The actual result is when my outermost transaction has not been ended, the wall movement done by the inner-ended transaction is executed and I can see its action on the screen by using 'TransactionManager.QueueForGraphicsFlush'

0 Likes
Message 8 of 8

artc2
Autodesk
Autodesk
That makes sense because you have made the changes to the wall, so even though that object hasn't yet closed, you can see it's changes if you queue it for graphics flush. but, associated objects typically are updated when the main object is closed - often via some reactor notification.
0 Likes