Author Topic: Handles?  (Read 4492 times)

0 Members and 1 Guest are viewing this topic.

whdjr

  • Guest
Handles?
« on: December 14, 2004, 06:26:08 PM »
I wrote a tool a while back to read some attributes from a base plan (using ObjectDBX) for a finish schedule.  The data is compiled into a list of strings.  Then a block is inserted into the current dwg for each space in the list and populated with each of the strings.  Now I would like to reverse the process and I wanted to get ya'lls ideas on the subject.  I need to use something to link the two blocks in the two files together.  I was thinking of using handles as they are unique to each object, that way even if every string in the list is changed the data is still populated in the correct block.  Please send any thoughts or advice you might have.

Thanks,

SMadsen

  • Guest
Handles?
« Reply #1 on: December 15, 2004, 04:25:29 AM »
Sounds like a nice project. Only comment here and now is that you should make sure to write code to validate the handles (and any owner of a matching handle) before using the owners.

whdjr

  • Guest
Handles?
« Reply #2 on: December 15, 2004, 08:59:00 AM »
Quote from: SMadsen
you should make sure to write code to validate the handles (and any owner of a matching handle) before using the owners.

How would I go about validating the handles and what potential problems could there be if they are not validated?

David Bethel

  • Swamp Rat
  • Posts: 656
Handles?
« Reply #3 on: December 15, 2004, 09:03:24 AM »
Code: [Select]
 (if (handent "1234")
      (princ "\nThe entitiy still exists")
      (princ "\nThe entitiy has been erased"))


-David
R12 Dos - A2K

whdjr

  • Guest
Handles?
« Reply #4 on: December 15, 2004, 09:39:32 AM »
I've noticed that each attribute has a handle as well as the parent attribute reference.  I was thinking of using xdata to attach the handle string name to each attribute in the schedule block.  Does that sound like it would work?  or too many holes?  I've written some tools that read xdata, but never any that wrote xdata.  Are there any peculiar things I need to be cautious of?

SMadsen

  • Guest
Handles?
« Reply #5 on: December 15, 2004, 10:03:53 AM »
Quote from: David D Bethel
Code: [Select]
 (if (handent "1234")
      (princ "\nThe entitiy still exists")
      (princ "\nThe entitiy has been erased"))

Basically something like that but "1234" might also be in use for a total unrelated entity, so maybe an extended verification would be in order.

XData would work, Will. Hidden attributes could also work but has the disadvantage of being editable. Dictionaries might be overkill. So yes, XData would work :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Handles?
« Reply #6 on: December 15, 2004, 10:59:13 AM »
Why not match the block name as well.

(if (and (= (handent) "1234") (= (blkname) "MyDataTable")))
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

daron

  • Guest
Handles?
« Reply #7 on: December 15, 2004, 11:13:12 PM »
I believe an object (block or otherwise) when it is blocked out or inserted in changes the handle information. If it's the 1534th item it takes on a handle that relates to it in hex code, I believe, and if it's the first object in it's new drawing, then it would take on the hex code for the number one place. Therefore, you won't always end up with the same handle. So, I think you might try another route. Suggestion, use block names or tagnames.

whdjr

  • Guest
Handles?
« Reply #8 on: December 16, 2004, 08:55:05 AM »
Thanks for the suggestion Daron, but I guess I didn't explain the situation too clearly.
Lets try this explaination and see if we get any further:

I made a Room block w/ attributes that gets inserted into a floor plan for each room/space.  The blocks attributes describe the room name, number, finishes, clg height, etc.(you know, all that jazz).  Each block has a unique handle and each attribute within that block has a unique handle, because that's the way Autocad wants it.  Ok.  Enough for that dwg.

Then I have another block that looks like a line item in a finish schedule.  It has an attribute for each column of that lineitem.

I wrote a lisp a while back that extracts all the data from each of attributes from the specified block from the floor plan and compiles the textstrings into an ordered list.  It opens this floor plan and retrieves the data either using ObjectDBX (if the user does not have the file open) or reads the dwg data from the Acad documents collection.  It then inserts my second block into a new dwg (which is the active dwg) and fills in the attributes with the strings from the ordered list.  It does this for each room/space so that when it is finished it looks like a Finish Schedule.  The tool also inserts a "header" block at the beginning and inserts a "blank" lineitem at increments of 10 or when the room numbers are not consecutive.  

Whew!  That was a mouthful.  With all that being said, now I would like to reverse the process.  We have found that once you make the schedule it is far easier to edit the schedule and have it update the plan than it is to edit the plan and have it update the schedule.  My thinking was when I made my ordered list from the attributes in the floor plan I would included their respective handles as well.  Then when I insert the second block I would attach the handles to each of the attributes using xdata so that each attribute is paired up with a specific attribute in the floor plan.  So even if we have a floor plan change (all the time) and the attributes are moved they will still update correctly.

Does this make it any clearer?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Handles?
« Reply #9 on: December 16, 2004, 10:27:42 AM »
One word of warning ... wblocking a drawing destroys all existing handles and recreates them reordered. This goes for a single entity, multiple, or the whole drawing.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Handles?
« Reply #10 on: December 16, 2004, 10:44:39 AM »
What does that do for x-data?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
Handles?
« Reply #11 on: December 16, 2004, 10:47:28 AM »
Quote from: Keith
wblocking a drawing destroys all existing handles and recreates them reordered. This goes for a single entity, multiple, or the whole drawing.

There should not be any reason they would ever need to wblock any of this.  I don't see this playing a factor here.  Thanks for the advice though.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Handles?
« Reply #12 on: December 16, 2004, 10:54:34 AM »
Quote from: CAB
What does that do for x-data?


XData remains attached, but if you reference a handle in the XData in the 1005 field, it will not be updated...unless they changed that in 2004+.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie