KiLLiNG-TiME 发表于 2022-7-6 23:25:34

A little help if possible (Ch

A little help if possible,
 
Does anybody know how to change the VP (viewport) colour of a layer by script or if its even possible.
 
Regards KT
 
p.s or lsp of course.

BlackBox 发表于 2022-7-6 23:37:47

It appears that you'll have to dig into a LayerTableRecord's Extension Dictionary's XRecord for this.
 
Cheers

KiLLiNG-TiME 发表于 2022-7-6 23:45:00

 
Thank you, just what I didn't want to hear

BlackBox 发表于 2022-7-6 23:50:18

Yeah, sorry... I got hit up for something, and posted quickly... Try this:
 

(defun c:FOO (/ eName layerName color) (if   (or   (and       (setq eName            (car (entsel "\nSelect entity to change VP color: "))       )       (setq layerName (cdr (assoc 8 (entget eName))))   )   (and       (setq layerName            (getstring T                         "\nEnter layer name to change VP color: "            )       )       (tblsearch "layer" layerName)   )   )    (if (setq color (acad_colordlg                      (if (= "BYLAYER" (setq color (getvar 'cecolor)))                        256                        color                      )                  )      )      (command "._vplayer" "_color" color layerName pause "")    ) ) (princ))

steven-g 发表于 2022-7-6 23:54:16

You could use a script, at least what I understand to be a script (LT mentality)

vplayercolorREDNameOfLayercurrent
the script should be finished with 2 presses of the enter key, and the script called up whilst a viewport is active. The color should be changed to suit and can include true color.

KiLLiNG-TiME 发表于 2022-7-7 00:02:21

Thank you both BlackBox & Steven-g I shall give both methods a go, much appreciated.
 
I though I knew AutoCAD quite well but I never knew there was a VPlayer command   , thanks again for that one.

RobDraw 发表于 2022-7-7 00:10:09

Don't know where I got this but use it quite often.
 

(defun c:lc (/ clr lay) (vl-load-com) (setq lay (cdr      (assoc 8 (entget   (car (entsel "\nSelect object to change layer color: ")) )      )    )clr (acad_colordlg 1) ) (if (and lay clr)   (vla-put-color   (vlax-ename->vla-object (tblobjname "layer" lay))   clr   ) ) (princ))

KiLLiNG-TiME 发表于 2022-7-7 00:18:52

Thank you Rob another one to try lsp wise.
 
The script is quite easy now that I know the VPLAYER command & works a treat.
 
Many thanks all for help.

samifox 发表于 2022-7-7 00:19:57

im running a script

^C^Cvplayer color 8 * Select
 
how can i pause it for user selection? for example i want to type the color index instead of fixed 8.

KiLLiNG-TiME 发表于 2022-7-7 00:25:53

 
You uses a backslash (\) at the point where you want to manually input.
 
 
Found a link for you
https://knowledge.autodesk.com/support/autocad-lt/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-LT/files/GUID-9D921CDD-89A3-44AB-865A-00F8986611F2-htm.html
页: [1]
查看完整版本: A little help if possible (Ch