Author Topic: *blockname Entity List ?  (Read 2437 times)

0 Members and 1 Guest are viewing this topic.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
*blockname Entity List ?
« on: January 12, 2014, 03:49:25 PM »
By inserting a block with the name preceded by *, the block is exploded upon insertion.  Is there a method to capture a list of the entities within the block prior to exploding, the entities must already be located in the drawing however so that the DXF values are correct.  (the entities in this case are attributes)

This list could be either a Selection Set List or Entity List.

I would like to use this list of entities to subsequently create a new block with additional entities in it. 

I have no problems converting this entity list into a selection set for the subsequent block command. 

Thanks,

Bruce
« Last Edit: January 12, 2014, 03:53:55 PM by snownut2 »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: *blockname Entity List ?
« Reply #1 on: January 12, 2014, 04:28:53 PM »
One algorithm involves identifying the current last entity in the database, exploding the block, then collecting entities from the previous last to the current last.

SuperFlatten by Joe Burke would be a good place to start looking. http://www.theswamp.org/index.php?topic=18153.0
look for a CommandExplode() function.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: *blockname Entity List ?
« Reply #2 on: January 12, 2014, 04:50:06 PM »
Thanks Kerry, I was drawing a blank, here's what I came up with..

Code - Auto/Visual Lisp: [Select]
  1.    (setq blk (strcat "*" blk)
  2.          ent (entlast)
  3.          )
  4.    (command "_.insert" blk pt1 "" "" )
  5.    (while (/= nil (setq ent (entnext ent)))
  6.      (setq lent-lst(cons ent lent-lst)
  7.            )
  8.      )  
  9.  

Seems to work fine.
« Last Edit: January 12, 2014, 05:16:37 PM by snownut2 »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: *blockname Entity List ?
« Reply #3 on: January 12, 2014, 05:17:17 PM »
You should take this into account:
Code: [Select]
: (entget (entlast))
((-1 . <Entity name: 156513e0>) (0 . "POLYLINE") (5 . "1AD7") (330 . <Entity name: 0ca92c80>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDb2dPolyline") (66 . 1) (10 0.0 0.0 0.0) (70 . 1) (40 . 0.0) (41 . 0.0) (71 . 0) (72 . 0) (73 . 0) (74 . 0) (210 0.0 0.0 1.0) (75 . 0))
: (entget (entnext (entlast)))
((-1 . <Entity name: 1564e4d0>) (0 . "VERTEX") (5 . "1AD8") (330 . <Entity name: 156513e0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbVertex") (100 . "AcDb2dVertex") (10 6.49894e+009 5.88777e+009 0.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (70 . 0) (50 . 0.0))
The same problem occurs if an insert with attributes is the last entity.

To avoid this:
Code: [Select]
(setq ent (entlast))
(while (setq tmp (entnext ent)) (setq ent tmp))

Or insert the block without exploding and use the (vla-expode) function.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: *blockname Entity List ?
« Reply #4 on: January 12, 2014, 05:21:57 PM »
Note:
Code: [Select]
(while (/= nil (setq ent (entnext ent)))
Is equivalent to:
Code: [Select]
(while (setq ent (entnext ent))

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: *blockname Entity List ?
« Reply #5 on: January 12, 2014, 05:23:37 PM »
Thanks Roy

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: *blockname Entity List ?
« Reply #6 on: January 12, 2014, 05:48:42 PM »
< .. >

Or insert the block without exploding and use the (vla-expode) function.

That is the road I'd take.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12924
  • London, England
Re: *blockname Entity List ?
« Reply #7 on: January 12, 2014, 05:56:09 PM »
I would like to use this list of entities to subsequently create a new block with additional entities in it.

For this I would personally use the ActiveX copyobjects method to copy the required objects from the block definition of the block in question directly to the block definition of the new block - this way, you also don't need to worry about transformations between block reference geometry and block definition geometry.