Author Topic: Special Layer translate LIST requred  (Read 8605 times)

0 Members and 1 Guest are viewing this topic.

sjeveni

  • Guest
Re: Special Layer translate LIST requred
« Reply #30 on: January 02, 2012, 03:58:38 AM »
Ya'll should keep in mind it's possible the OP isn't indicating the full requirements of this thread's request: when binding xrefs all table entries (e.g. layers, text styles yada) inherit the *$0$* sh!t. Subtitle: the intelligent stripping / merging may have to be performed on more than just layers. I may be wrong, on the other hand, I may be wrong.

This One worked Fine:

(vl-load-com)
(defun c:LayerClean (/ layers lo name badlayers name1 pos)
  (setvar "CLAYER" "0")
  (setq layers (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object))))
  (vlax-for lo layers
    (setq name (vla-get-Name lo))
    (cond
      ((and (vl-string-search "$" name) (not (vl-string-search "|" name)))
       (setq badlayers (cons name badlayers))
      )
    )
  )

  (foreach name badlayers
    (setq name1 name
          lo (vla-Item layers name)
    )
    (while (setq pos (vl-string-search "$" name1))
      (setq name1 (substr name1 (+ pos 2)))
    )
    (cond
      ((tblsearch "LAYER" name1)
       (command "-LAYMRG" "_Name" name "" "_Name" name1 "_Yes")
      )
      (t
       (vla-put-Name lo name1)
      )
    )
  )
  (princ)
)




Can someone edit this to include also blocks renaming.
Layers all OK now even those in Blocks. But blocks names are still with 4176-x_(something)$0$(real block name).
« Last Edit: January 02, 2012, 04:52:44 AM by sjeverni »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Special Layer translate LIST requred
« Reply #31 on: January 02, 2012, 09:48:42 AM »
...

Hm... I don't understand.
when I installed this lisp frst time, all went fine, it did job pefrectly. So I said to give it a try again on some other drawing and it didn't work.
So I shut down my AutoCAD and instaled lisp again and got message:

Command: _appload merge2delim.LSP successfully loaded.
Command: ; error: bad argument type: lentityp nil
Command:
Command: merge2delim
; error: bad argument type: lentityp nil

Can you post a sample drawing?

**EDIT I reposted the code in the original post to include some catch-all statements. Let me know if that fixes yours errors.
« Last Edit: January 02, 2012, 10:12:38 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

sjeveni

  • Guest
Re: Special Layer translate LIST requred
« Reply #32 on: January 03, 2012, 01:54:09 AM »
Ronjonp,
- when I loaded lisp it did the job automatically without typing command, just when I closed Load/unload applications screen. I didn't liked that.
- when I wanted to do the same on othed drawing (by typing command) got an error message Unknown command. Strange, isn't it?
- Frst time jobe was done almost perfectlly. There was 3 or 4 layers lefted unchanged.
- Block names are lefted unchanged, could you please include in lisp cleaning of block names same as on layers (all before and including $0$).
Sending you a part of drawing that you can test on.

Best Regards,
S.

P.S. Btw. it is very fast, much faster than LayerClean lisp (althrought this one actually work on command, not by it self :D)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Special Layer translate LIST requred
« Reply #33 on: January 03, 2012, 03:22:24 PM »
Ronjonp,
- when I loaded lisp it did the job automatically without typing command, just when I closed Load/unload applications screen. I didn't liked that.
- when I wanted to do the same on othed drawing (by typing command) got an error message Unknown command. Strange, isn't it?
- Frst time jobe was done almost perfectlly. There was 3 or 4 layers lefted unchanged.
- Block names are lefted unchanged, could you please include in lisp cleaning of block names same as on layers (all before and including $0$).
Sending you a part of drawing that you can test on.

Best Regards,
S.

P.S. Btw. it is very fast, much faster than LayerClean lisp (althrought this one actually work on command, not by it self :D)

I updated the original code to include renaming blocks and used the -laymrg at the end to check for layers not merged. Let me know how it goes :).

http://www.theswamp.org/index.php?topic=40535.15
« Last Edit: January 03, 2012, 03:26:36 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

sjeveni

  • Guest
Re: Special Layer translate LIST requred
« Reply #34 on: January 04, 2012, 01:33:34 AM »
Command: merge2delim
; error: Automation Error. Duplicate record name

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Special Layer translate LIST requred
« Reply #35 on: January 04, 2012, 09:28:19 AM »
Command: merge2delim
; error: Automation Error. Duplicate record name

Updated to add another catch-all ... try it again.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

sjeveni

  • Guest
Re: Special Layer translate LIST requred
« Reply #36 on: January 04, 2012, 10:50:26 AM »
Seems to work perfectlly.
Geve me little bit more time to test it on few different drawings.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Special Layer translate LIST requred
« Reply #37 on: January 04, 2012, 12:24:13 PM »
Seems to work perfectlly.
Geve me little bit more time to test it on few different drawings.

Good deal  8-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC