rcb007 Posted April 9, 2020 Share Posted April 9, 2020 I stumbled upon this routine which is simple enough I could follow. But I am having a hard time trying to figure out how to make (2) routines from this. - One routine that will just change the lineweight of the selected layer object. - Second routine which will change the plot styles of the selected layer. (defun C:CHCOLPICK (/ lay col) (setq lay (cdr (assoc 8 (entget (car (nentsel "\nObject on Layer to assign color to: "))))) col (acad_colordlg (cdr (assoc 62 (tblsearch "layer" lay))) nil) ) (command "_.layer" "_color" col lay "") (princ) ) Any help would be great! Thank you. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 10, 2020 Share Posted April 10, 2020 Using a bit of vl if you have a look at the properties, Plotstylename is one of them so can use a If = layername (vla-put-PlotStyleName lay "xxxx") test on a dwg with a couple of layers. (setq doc (vla-get-activedocument (vlax-get-acad-object))) ; open database (vlax-for lay (vla-get-layers doc) (vlax-dump-object lay) ) Quote Link to comment Share on other sites More sharing options...
rcb007 Posted April 10, 2020 Author Share Posted April 10, 2020 I think I understand, that the above code does for dumping all the variables. I guess, how do I properly place the variable within the routine? (defun C:LWPICK (/ lay ps) (setq lay (cdr (assoc 8 (entget (car (nentsel "\nObject on Layer to assign plotstyle to: "))))) ;col (acad_colordlg (cdr (assoc 62 (tblsearch "layer" lay))) nil) ps ((vla-put-PlotStyleName lay "") nil) ) (command "_.layer" "_color" ps lay "") (princ) ) Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted April 10, 2020 Share Posted April 10, 2020 1 hour ago, rcb007 said: I think I understand, that the above code does for dumping all the variables. I guess, how do I properly place the variable within the routine? (defun C:LWPICK (/ lay ps) (setq lay (cdr (assoc 8 (entget (car (nentsel "\nObject on Layer to assign plotstyle to: "))))) ;col (acad_colordlg (cdr (assoc 62 (tblsearch "layer" lay))) nil) ps ((vla-put-PlotStyleName lay "") nil) ) (command "_.layer" "_color" ps lay "") (princ) ) Perhaps like this? (defun c:lwpick ( / adoc lay obj vlay) (while (null (setq obj (entsel "\nObject on layer to assign ploystyle to: "))) (princ "\nNothing selected")) (setq lay (cdr (assoc 8 (entget (car obj)))) adoc (vla-get-ActiveDocument (vlax-get-acad-object)) vlay (vla-item (vla-get-layers adoc) lay) ) (vla-put-Color vlay <your_color>) (vla-put-PlotStyleName vlay <your_style_name>) ) If you inspect (vla-item (vla-get-layers adoc) "0") or any vla-object, you can see a full list of properties that you can modify by using vla-put-. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.