Author Topic: automatizeing refedit  (Read 5271 times)

0 Members and 1 Guest are viewing this topic.

S.Langhammer

  • Guest
automatizeing refedit
« on: May 22, 2013, 09:42:48 AM »
Hello there,
is there any possible way, to address blocks directly from the block list for rededit?

The function I aim at should walk through the block list, exploding every polygone mesh (polyline, flag 16 set) completly without any user interaction, running in the background.

I don't know refedit well by now. Considering Lisp-scripts the following is my best clue:
http://www.theswamp.org/index.php?topic=43715.msg489819#msg489819
Which implies, that you can only select inserts by coordinates. Yet the help tells you can click the insert as well: http://www.bricsys.com/bricscad/help/en_US/V11/UsrGui/source/12_Blocks_Attributes_External_References/12_02_Editing_blocks_and_external_references.htm Which makes me think there could be a way to acces a block, or at least an insert via its entity Name.

In case there is no way to do that, does anyone know a proper alternative for me?

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: automatizeing refedit
« Reply #1 on: May 22, 2013, 09:58:43 AM »
Do you mean refedit / bedit? I'd advise using bedit for such, you can obtain the blocks' names through tblnext. Then simply pass the name to the bedit command so it edits that block, then use ssget to select the polygon meshes and send its result to the explode command (or use the activex explode method on each). then send the bsave & bclose commands to finish editing the block - step to next in tblnext and repeat process until tblnext returns nil.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

S.Langhammer

  • Guest
Re: automatizeing refedit
« Reply #2 on: May 22, 2013, 10:02:36 AM »
I Keep forgetting to mention this: I use BricsCAD.
That does not know a lot of AutoCAD commands, so as it seems, bedit is included to that list to.

Otherwise your Routine would work brilliantly.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: automatizeing refedit
« Reply #3 on: May 22, 2013, 11:08:17 AM »
I Keep forgetting to mention this: I use BricsCAD.
That does not know a lot of AutoCAD commands, so as it seems, bedit is included to that list to.
I must disagree here. BricsCAD does 'know' a lot of AutoCAD commands, but not all.

To call REFEDIT from Lisp in BricsCAD you have to use something like this:
Code - Auto/Visual Lisp: [Select]
  1. (command "refedit" (list <enameOfInsert> <pointOnInsert>) "_ok" "_all" "_yes")
This will most likely not work for you.

But this works:
Code - Auto/Visual Lisp: [Select]
  1. (defun test (blockName) ; BlockName must point to a valid block .
  2.   (mapcar
  3.     '(lambda (object)
  4.       (if (= (strcase (vla-get-objectname object)) "ACDBPOLYGONMESH")
  5.         (progn
  6.           (vla-explode object)
  7.           (vla-erase object) ; (vla-explode) does not erase the original object.
  8.         )
  9.       )
  10.     )
  11.     (vla-collection->list ; BricsCAD function.
  12.       (vla-item
  13.         blockName
  14.       )
  15.     )
  16.   )
  17. )

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: automatizeing refedit
« Reply #4 on: May 22, 2013, 11:16:01 AM »
Alternative with (vlax-for):
Code - Auto/Visual Lisp: [Select]
  1. (defun test2 (blockName)
  2.   (vlax-for object
  3.     (vla-item
  4.       blockName
  5.     )
  6.     (if (= (strcase (vla-get-objectname object)) "ACDBPOLYGONMESH")
  7.       (progn
  8.         (vla-explode object)
  9.         (vla-erase object) ; (vla-explode) does not erase the original object.
  10.       )
  11.     )
  12.   )
  13. )

S.Langhammer

  • Guest
Re: automatizeing refedit
« Reply #5 on: May 22, 2013, 11:19:56 AM »
@roy:
I must apologize. I'm not actually sure, which commands BricsCAD and AutoCAD actually share. It's just that I feel a little, like i'm bumping into those, they don't share.
Specially bedit could have simplified a lot.

Could you give a short summary of what vla-item, vla-get-blocks and vlax-get-acad-object do? or link me some kind of cheat sheet?


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: automatizeing refedit
« Reply #6 on: May 22, 2013, 11:41:10 AM »
Could you give a short summary of what vla-item, vla-get-blocks and vlax-get-acad-object do?
You can click on the keywords in the lisp code blocks on this forum.
If you need more information you can try these useful links:
http://entercad.ru/acadauto.en/ (Object Model)
http://docs.autodesk.com/ACD/2011/ENU/landing.html
http://www.afralisp.net/index.php

S.Langhammer

  • Guest
Re: automatizeing refedit
« Reply #7 on: May 23, 2013, 02:45:38 AM »
Whoops!
Clicking it didn't redirect me straight to the entry in the Lisp help, like for example clicking defun. So I thought it wasn't in the list.
My bad!

S.Langhammer

  • Guest
Re: automatizeing refedit
« Reply #8 on: May 23, 2013, 03:58:19 AM »
By now I properly inserted your code (decided for the vlax-for method) and it does exactly, what I needed it to do!
Do you have a Website? Or any way I could donate to some PayPal account or something? you helped me out so much up until now and help me understand Lisp a lot better, than I did in the begining, that I just wanna repay you somehow.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: automatizeing refedit
« Reply #9 on: May 24, 2013, 09:00:19 AM »
Thank you for your kind words. I do not expect any payment for my modest contributions to this forum. But if you want to show your appreciation in monetary terms, why not donate to TheSwamp?