Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change m-leader color

24 REPLIES 24
Reply
Message 1 of 25
cadman777
3280 Views, 24 Replies

change m-leader color

Does anybody have a simple lisp (no v.b.) program that changes the color of m-leader lines in acad 2010?

TIA ...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
24 REPLIES 24
Message 2 of 25
jggerth1
in reply to: cadman777

is there a reason to not just select them and change the properties in the properties palette?

Message 3 of 25
Hallex
in reply to: cadman777

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

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 25
DRossger
in reply to: cadman777
Message 5 of 25
cadman777
in reply to: cadman777

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

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 6 of 25
DRossger
in reply to: cadman777

Have you typed in for "New color"  256, that aspect bylayer ?

Message 7 of 25
cadman777
in reply to: DRossger

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?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 8 of 25
stevor
in reply to: cadman777

Try to replace the line: (vla-setrgb trcol 59 93 181) ; set true color by RGB with: (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
Message 9 of 25
stevor
in reply to: stevor

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

S
Message 10 of 25
hmsilva
in reply to: cadman777

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

EESignature

Message 11 of 25
cadman777
in reply to: stevor

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.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 12 of 25
hmsilva
in reply to: cadman777

Post a sample dwg, it is easier...

 

Henrique

EESignature

Message 13 of 25
cadman777
in reply to: hmsilva

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
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 14 of 25
hmsilva
in reply to: cadman777

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

EESignature

Message 15 of 25
hmsilva
in reply to: cadman777

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

EESignature

Message 16 of 25
cadman777
in reply to: hmsilva

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
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 17 of 25
hmsilva
in reply to: cadman777

Chris
works for me, or I'm not to understand your question...

 

before using the lisp

 

1.PNG

 

after using the lisp

 

2.PNG

 

Henrique

EESignature

Message 18 of 25
cadman777
in reply to: hmsilva

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
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
Message 19 of 25
hmsilva
in reply to: cadman777

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

EESignature

Message 20 of 25
3wood
in reply to: cadman777

Please also try attached CHZ20.vlx

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost