ASSOC - Layers sublist (?? . VPcolor)

ASSOC - Layers sublist (?? . VPcolor)

gustavobernardi
Advocate Advocate
973 Views
4 Replies
Message 1 of 5

ASSOC - Layers sublist (?? . VPcolor)

gustavobernardi
Advocate
Advocate

I'm trying to make a lisp which will change layers with a specific color (E.g "Magenta") to a specific VPColor (E.g "Cyan"), but I don't know how is the value for VPcolor in the index of layer list.

When I list the properties, the prompt shows me only a few numbers of atoms:

 

((0 . "LAYER") (2 . "pilarete") (70 . 0) (62 . 6) (6 . "Continuous"))

 

How to get the VPcolor and where I can get the complete list?

 

TIA

0 Likes
Accepted solutions (2)
974 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

 

As far as i know, you cannot access to the viewport layer overrides with LISP.

Some times ago I wrote some LISP extension function witn .NET including a gc-VpLayerOverride LISP function.

You can download a zip file contaning the C# source codes the application DLLs (NETLOAD LispvpLayer for AutoCAD 2013+) and a .chm help file (in English) from TheSwamp.

You can also find the LispExtension plugin on this page which contains an installer (LispExtensionSetup.msi) and see in the help file (French) that this version contains even more LISP functions.

 

Do not forget to "unblock" the attached .chm files.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 5

ronjonp
Mentor
Mentor
Accepted solution

A bit of a kludge but could automate some of it:

(defun _foo (l / b c)
  ;; RJP » 2018-11-01
  (vlax-for a (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
    (cond ((setq d (assoc (vla-get-color a) l))
	   (setq b (cons (cons (strcat (vla-get-name a) ",") (cdr d)) b))
	  )
    )
  )
  (cond	((and b)
	 (foreach c b (command "_.vplayer") (command "color" (cdr c) (car c) "Current" ""))
	 ;; (setq c (apply 'strcat (mapcar 'car b)))
	)
  )
  (princ)
)
(vl-load-com)
;; List that changes color 3 to color 73, 1 to 81 and so on...
(_foo '((3 . 73) (1 . 81)(6 . 61)))

image.png

Message 4 of 5

gustavobernardi
Advocate
Advocate

Thanks for answering. It worked fine. 

There's a way to use a named value, like this:

 

(setq LR3 1)(setq LR1 8)(setq LR6 4)

(_foo '((3 . LR3) (1 . LR1)(6 . LR6)))

 

I also tried turning into list:

(setq LR3 1)(setq LR1 8)(setq LR6 4)
(_foo '((3 . (list LR3)) (1 . (list LR1))(6 . (list LR6))))

This will make feasible the creation of DCL with choice according to the situation.

 

 

0 Likes
Message 5 of 5

ronjonp
Mentor
Mentor
Accepted solution

You'll need to format your list like so assuming those are your variables holding different integers.

(_foo (list (cons 3 lr3) (cons 1 lr1) (cons 6 lr6)))
0 Likes