Does anybody have a simple lisp (no v.b.) program that changes the color of m-leader lines in acad 2010?
TIA ...
Here you go
(defun C:mldCol(/ adoc layts n trcol) (vl-load-com) (setq adoc(vla-get-activedocument (vlax-get-acad-object)) layts (vla-get-layouts adoc)) (setq n 0) (vlax-for lt layts (vlax-for obj (vla-get-block lt) (if (eq "AcDbMLeader"(vla-get-objectname obj)) (progn (setq n (1+ n)) ;; get truecolor of mleader (setq trcol (vla-get-truecolor obj)) (vla-setrgb trcol 59 93 181);set true color by RGB ;;Or use instead ColorIndex: ;(vla-put-colorindex trcol 152); ;; bypass locked layers (will be ignored) (vl-catch-all-apply 'vla-put-LeaderLineColor (list obj trcol)) (vlax-release-object trcol))))) (vla-regen adoc acAllViewports) (princ (strcat "\nProcessed: " (itoa n) " mleaders")) (princ) )
Hallex/Cadplayer,
Thanks for the lisp routines.
I tried changing the routines to get them to change all leader lines to "bylayer".
However, based on my release 14 knowledge of lisp, nothing I did worked.
Obviously, I don't understand the relationship between "truecolor", "colorbook" and "bylayer" color.
Can you enlighten me, or give me something simple to read that informs me?
Also, how would you change your routines to select all mleaders in a dwg and change them to bylayer?
Thanks ...
Honestly, I don't know any visual lisp.
My acad 2010 doesn't have "vla-setrgb" command in Customization Help, so I don't know how it works.
That is why I quit writing lisp, b/c it kept changing and got beyond me.
I am a machine designer instead of a programmer.
Hallex posted the routine that I like, b/c it's automatic.
I do not want to make any user input, it needs to be automatic.
I need it to process drgs made in inventor, which I send to the shop as dwg, but they need proper formatting.
Thanks ...
PS: Where is the online v-lisp command reference?
Always a new surprise, at this forum.So I try Rich Text:
Try to replace the line:
(vla-setrgb trcol 59 93 181)
with the line:
(vla-put-colorindex trcol 152)
by using any text editor
That is what he probably meant by:
;;Or use instead ColorIndex:
;(vla-put-colorindex trcol 152);
S
Use de Hallex code witht colorindex 256...
(defun C:mldCol(/ adoc layts n trcol) (vl-load-com) (setq adoc(vla-get-activedocument (vlax-get-acad-object)) layts (vla-get-layouts adoc)) (setq n 0) (vlax-for lt layts (vlax-for obj (vla-get-block lt) (if (eq "AcDbMLeader"(vla-get-objectname obj)) (progn (setq n (1+ n)) ;; get truecolor of mleader (setq trcol (vla-get-truecolor obj)) ;(vla-setrgb trcol 59 93 181);set true color by RGB ;;Or use instead ColorIndex: (vla-put-colorindex trcol 256); ;; bypass locked layers (will be ignored) (vl-catch-all-apply 'vla-put-LeaderLineColor (list obj trcol)) (vlax-release-object trcol))))) (vla-regen adoc acAllViewports) (princ (strcat "\nProcessed: " (itoa n) " mleaders")) (princ) )
Henrique
Thanks for the advice.
Unfortunately it didn't work.
Here's what's happening:
1. I export an idw file out of inventor into an acad dwg file.
2. then run a script/lisp routine to properly format the drg.
3. the mleaders and leaders change to bylayer in the toolbar, but remain as override colors in the properties dialogue.
4. the way I change the leader colors is to manually filter-select all leaders, and then change them in the properties dialogue using mouse clicks in the boxes.
5. if I use filter-select all leaders, then try to use commandline change, i don't know what to do to make it change to bylayer.
the problem is, i don't know what inventor does to the entities, nor all the post release 14 acad lisp commands and details. also, it's 'overload' for me to begin learning it. too bad adsk didn't keep lisp simple for dumdum mechanical guys like me, who bought the program to do machine design and shop drgs, instead of PRESENTATION & PROFIT.
Henrique,
Thanks for the help.
Find attached 2 of the same drg:
1. as-exported from inventor
2. same drg as modified by my script-lisp routine
Note: look at leaders in #2 dwg file (the white leaders are the 'offenders' i'm trying to change)
Thanks ...
Chris,
you don'tt have "mleaders" you have "leaders"...
now I'm in the middle of a project, later I'll post a code to fix it ..
EDITED:
(defun c:test (/ ss) (if (setq ss (ssget "_X" '((0 . "LEADER")))) (command "chprop" ss "" "C" "BYL" "") );; if );; test
Test this code...
Henrique
Chris,
if you have Leaders and Mleaders in the dwg's, change
(ssget "_X" '((0 . "LEADER")))
to
(ssget "_X" '((0 . "*LEADER")))
it will select leaders and mleader...
hope that helps
Henrique
Thanks Henrique.
Unfortunately, I still have "bylayer" in the tool bar and "white" in the properties dialogue.
The selection set works, but the properties change doesn't.
That is why I'm stuck.
I don't know enough to troubleshoot what's wrong with either acad or the lisp routine.
Remember that this dwg file was produced by inventor 2010, not native acad.
Have you tried it on your computer with my drgs?
Chris
works for me, or I'm not to understand your question...
before using the lisp
after using the lisp
Henrique
Sorry for the confusion, Henrique.
It's the "dim line color" that needs to change (i.e., the leader line).
Your screen shots show the same as mine.
Look at the "dim line color" in your screen shot, and see what I mean.
My 2nd dwg file shows the same thing, except the leader lines don't update to "bylayer" in the "dim line color" field, so they show as color 8/white on screen.
See attached screen shot.
Chris,
minimally tested...
(defun c:test (/ ss vlaObj) (if (setq ss (ssget "_X" '((0 . "LEADER")))) (progn (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)) ) ) (vlax-for vlaObj ss (vlax-put-property vlaObj 'DimensionLineColor 256) (vla-put-color vlaObj 256) (vlax-release-object vlaObj) );; vlax-for );; progn );; if )
Henrique