ObjectARX

ObjectARX

Reply
Contributor
11 Posts
0 Kudos
Registered: ‎11-07-2011
Post 1 of 6

Block attributes auto-update

565 Views, 5 Replies
11-28-2011 02:53 AM

 

 

I want to do the following: import a block reference with attributes among which there are those that should contain the current coordinates of an entity from that block, and when I move that block those attributes should be updated in order to keep showing the current coordinates, the same way the dimensions are showing actual measurements even when resized.

 

I've tried to do this with fields in the attributes. But fields are not updated automatically on i.e. move command and I read that it could be time consuming for larger drawings.

 

So, the question is, how do I do this without developing custom entities?

 

EDIT: I forgot to mention that I'm doing this in Visual C++ 2005 with ObjectARX for AutoCAD 2008.

Moderator
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 2 of 6

Re: Block attributes auto-update

12-01-2011 01:34 PM in reply to: mihajlovic.milosh

mihajlovic.milosh wrote:

 

I've tried to do this with fields in the attributes. But fields are not updated automatically on i.e. move command and I read that it could be time consuming for larger drawings.

 

So, the question is, how do I do this without developing custom entities?

 


Maybe reactors?


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Contributor
11 Posts
0 Kudos
Registered: ‎11-07-2011
Post 3 of 6

Re: Block attributes auto-update

12-01-2011 01:46 PM in reply to: mihajlovic.milosh

Could you recommend me something where I can read how to implemet reactors?

Moderator
1,465 Posts
277 Kudos
Registered: ‎04-09-2008
Post 4 of 6

Re: Block attributes auto-update

12-01-2011 01:52 PM in reply to: mihajlovic.milosh

ObjectARX Developer's Guide -> Advanced Topics -> Notification -> Using Reactors


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Valued Contributor
70 Posts
1 Kudo
Registered: ‎02-17-2005
Post 5 of 6

Re: Block attributes auto-update

12-16-2011 09:29 AM in reply to: mihajlovic.milosh

Not quite what you want, but I think may help.

Add a handler to the ObjectModified Event thus:-

      CurDb = Application.DocumentManager.MdiActiveDocument.Database
      AddHandler CurDb.ObjectModified, AddressOf ObjectModified

 and add this event.

 

   Friend Sub ObjectModified(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs)
      If isMod Then Exit Sub
      Dim b As Boolean
      With e.DBObject
         If .IsWriteEnabled Then Exit Sub
         If .Id.ObjectClass.Name = "AcDbAttribute" Then
            Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
               Dim ar As AttributeReference = CType(e.DBObject, AttributeReference)
               With a_Job
                  ar.UpgradeOpen()

' add you code here and if you make an amendment, set b=True

                 If b Then isMod = True : ar.DowngradeOpen() ' isMod prevents loop
               End With
               tr.Commit()
            End Using
         End If
      End With
      isMod = False
   End Sub

 Your code will update tags where needed

Valued Contributor
70 Posts
1 Kudo
Registered: ‎02-17-2005
Post 6 of 6

Re: Block attributes auto-update

12-16-2011 09:31 AM in reply to: stuartnathan

ps.

You may need to trap the block object instead.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post