Jump to content

A little help if possible (Changing VP layer colour by script)


KiLLiNG-TiME

Recommended Posts

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.

Link to comment
Share on other sites

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

 

Cheers

 

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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

vplayer
color
RED
NameOfLayer
current

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.

Link to comment
Share on other sites

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 :roll: , thanks again for that one.

Edited by KiLLiNG-TiME
Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 years later...

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.

Link to comment
Share on other sites

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.

 

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

Edited by KiLLiNG-TiME
updating
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...