Author Topic: Layer vs -Layer issue  (Read 4224 times)

0 Members and 1 Guest are viewing this topic.

Serge J. Gianolla

  • Guest
Layer vs -Layer issue
« on: April 13, 2010, 11:15:20 PM »
When in Layer Manager dialogue box, if you highlight one layer and create a new one, it will have same parameters to the highlighted one. Is there a way to make it behave same from command line? What am I missing? It always creates layer with default value [continuous, white...].
Any idea? Nothing fancy, it is for the macro side of a ToolPalette even Diesel if it can cope!
Thanx

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Layer vs -Layer issue
« Reply #1 on: April 14, 2010, 07:29:03 AM »
I would avoid the command call altogether and would copy all the properties of a layer using VL or AutoLISP - it might be less prone to error that way  :-)

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Layer vs -Layer issue
« Reply #2 on: April 14, 2010, 09:18:37 AM »
Perhaps something like:

Code: [Select]
(defun CopyLayerProps (source dest / itemp layers)
  ;; Lee Mac  ~  14.04.10
 
  (defun itemp (coll item)
    (if (not (vl-catch-all-error-p
               (setq result (vl-catch-all-apply
                              (function vla-item) (list coll item)
                            )
               )
             )
         )
      result
    )
  )

  (if (setq source
        (itemp
          (setq layers (vla-get-Layers
                         (vla-get-ActiveDocument
                           (vlax-get-acad-object)
                         )
                       )
           )
          source
        )
      )                         
    (progn
      (setq dest (cond (  (itemp layers dest))
                       (  (vla-Add layers dest))
                 )
      )
      (and
        (mapcar
          (function
            (lambda ( property )
              (if (vlax-property-available-p source property)
                (vlax-put-property dest property
                  (vlax-get-property source property)
                  )
                )
              )
            )
          '(Color Description Freeze
            LayerOn Linetype Lineweight
            Lock Material Plottable ViewportDefault)
        )
      )
    )
  )
)


Code: [Select]
(CopyLayerProps "Old Layer" "New Layer")

New Layer will be created if non-existent
« Last Edit: April 14, 2010, 09:25:03 AM by Lee Mac »

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Layer vs -Layer issue
« Reply #3 on: April 14, 2010, 10:14:21 AM »
Nothing fancy, it is for the macro side of a ToolPalette even Diesel if it can cope!
Perhaps something like:
.....

 :lmao:

I'm not picking on you Lee, I just thought it was funny.

Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Layer vs -Layer issue
« Reply #4 on: April 14, 2010, 10:18:06 AM »
Yeah, I suppose it wasn't too concise...  :|

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Layer vs -Layer issue
« Reply #5 on: April 14, 2010, 10:20:28 AM »
Yeah, I suppose it wasn't too concise...  :|
As much as it could be.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Serge J. Gianolla

  • Guest
Re: Layer vs -Layer issue
« Reply #6 on: April 14, 2010, 06:13:34 PM »
Thanks guys.
The idea of using command is for portability and maintainance! As a macro it is built in the ToolPalette that can be sent to our interstates or o'seas branches. No need to send a lisp/vlx file, with all issues that may crop along. But ultimately the question still remains! Why is the behaviour different if you go via dialogue instead of command? I am not used to that in AutoCAD.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Layer vs -Layer issue
« Reply #7 on: April 14, 2010, 07:15:58 PM »
Thanks guys.
The idea of using command is for portability and maintainance! As a macro it is built in the ToolPalette that can be sent to our interstates or o'seas branches. No need to send a lisp/vlx file, with all issues that may crop along. But ultimately the question still remains! Why is the behaviour different if you go via dialogue instead of command? I am not used to that in AutoCAD.
-Layer just wasn't coded that way. At best, it could take on the properties of the current layer, but it obviously doesn't do that.

You have to understand, -Layer predates the Layer Manager GUI.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Serge J. Gianolla

  • Guest
Re: Layer vs -Layer issue
« Reply #8 on: April 14, 2010, 07:46:58 PM »
Yeah, but all commands from prompt line predate dialogue box driven ones! Array is the same regardless the method one is using, this is done in order to help with routines that were created 1278 years ago  :lmao: so is Block making or PLOT [bar the number of plots]...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Layer vs -Layer issue
« Reply #9 on: April 14, 2010, 07:51:53 PM »
< .. >

You have to understand, -Layer predates the Layer Manager GUI.



also, -Layer was designed for people who know how to use a keyboard   :wink:
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.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Layer vs -Layer issue
« Reply #10 on: April 14, 2010, 07:52:52 PM »
< .. >  help with routines that were created 1278 years ago  :lmao:  ...

 :-D
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.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Layer vs -Layer issue
« Reply #11 on: April 14, 2010, 09:10:31 PM »
< .. >

You have to understand, -Layer predates the Layer Manager GUI.



also, -Layer was designed for people who know how to use a keyboard   :wink:
The GUI Layer Manger was already around when I started, but as soon as I found -layer, I changed my pgp and never looked back. The only reason I ever open the GUI is to change layer color/linetype properties in the viewport.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12916
  • London, England
Re: Layer vs -Layer issue
« Reply #12 on: April 15, 2010, 06:34:12 AM »
Surely the way to do it is to use LISP/VLX and avoid command calls - they are the main reason programs don't work in later versions.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Layer vs -Layer issue
« Reply #13 on: April 15, 2010, 08:28:31 AM »
Surely the way to do it is to use LISP/VLX and avoid command calls - they are the main reason programs don't work in later versions.
Not if it needs to be accomplished with macros, placed within a button or ToolPalette palette.

Just for the record, I have an old set of layer commands (all written with use of command calls) that were written back in 93 that were given to me by an engineer I used to work for. I used them until I learned how to write my own and I know he's still using them to this day.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

curmudgeon

  • Newt
  • Posts: 194
Re: Layer vs -Layer issue
« Reply #14 on: April 15, 2010, 01:50:45 PM »
This is embarrassing. I have known most of what I need and forgotten. I would like to write for myself a simplified version of lman, just to switch between half a dozen preset layer states. I have used pull down menus, and I guess that was scripts. But I would like to do it with lisp.

I am slowly coming around to really liking vl-sort, but other than that, if it starts with "vl" I have not needed it - yet.

I can handle the symbol tables well enough, but the LAYERS table is not editable, in the same fashion as others. But it seems I remember a there is a way, or was, to simply freeze & thaw from pure lisp, and that is what I am after.

thanks

roy
Never express yourself more clearly than you are able to think.