View Full Version : Leader Lisp With Tag
BCrouse
2005-10-28, 03:08 PM
Can someone help me out with a lisp the uses a leader and it has a tag attached at the end ot the tail. The tags are attribute. Can the lisp please apply the leader to this layer (A-Anno-Note)?
Thank you,
Brad
Can someone help me out with a lisp the uses a leader and it has a tag attached at the end ot the tail. The tags are attribute. Can the lisp please apply the leader to this layer (A-Anno-Note)?
Thank you,
Brad
Hi Brad
There is idea only, but maybe this will help to you
Make blocks with name "SQUARE-NUMBER" "TRIANGLE-NUMBER" and "ROUND-NUMBER"
and than run this routine (of course it's very quick and dirty)
No warranty
Thank you
f.
(defun set-lay (cdoc l_name lt_name col / alrs alts nl tbl tblt tmp tmp1)
(setq alrs (vla-get-layers cdoc)
alts (vla-get-linetypes cdoc)
tbl (vlax-for l_item alrs
(setq tmp (cons (vla-get-name l_item) tmp)))
tblt (vlax-for lt_item alts
(setq tmp1 (cons (vla-get-name lt_item) tmp1)))
)
(if (not (member lt_name tblt))
(vla-load alts (strcase lt_name) "acadiso.lin")) ;or acad.lin
(if (member l_name tbl)
(progn
(if (/= (vla-get-name (vla-get-activelayer cdoc)) l_name)
(setq nl (vla-put-activelayer cdoc (vla-add alrs l_name)))
(setq nl (vla-get-activelayer cdoc))
)
(vla-put-color (vla-item alrs l_name) col)
(vla-put-linetype nl lt_name)
)
(progn
(setq nl (vla-add alrs l_name))
(vla-put-activelayer cdoc nl)
(vla-put-color (vla-item alrs l_name) col)
(vla-put-linetype nl lt_name)
)
)
(if (/= (vlax-variant-value
(vla-getvariable cdoc "CECOLOR"))
"BYLAYER")
(vla-setvariable cdoc "CECOLOR" "BYLAYER")
)
(if (= (vla-get-layeron nl) :vlax-false)
(vla-put-layeron nl :vlax-true)
)
(if (= (vla-get-freeze nl) :vlax-true)
(vla-put-freeze nl :vlax-false)
)
(if (= (vla-get-lock nl) :vlax-true)
(vla-put-lock nl :vlax-false)
)
(princ)
)
(prompt "\n\t\t>>> Type TLD to run routine")
(defun C:tld (/ acsp adoc anno_blk atts clr lead mtpt nmb
oclr oexp otm pt ptlist tmparray tmpvar)
(vl-load-com)
(setq oclr (getvar "CLAYER"))
(setq otm (getvar "ORTHOMODE"))
(setq oexp (getvar "EXPERT"))
(setvar "ORTHOMODE" 0)
(setvar "EXPERT" 0)
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)))
(setq acsp (vla-get-modelspace adoc))
(vla-endundomark adoc)
(vla-startundomark adoc)
(setq nmb (getstring "\nEnter block number : \n"))
(initget "S T R")
(setq ans (getkword "\nChoose block type [S]quare [T]riangle [R]ound <S>"))
(if (not ans) (setq ans "S"))
(setq blk_name
(cond ((eq ans "S") "SQUARE-NUMBER")
((eq ans "T") "TRIANGLE-NUMBER")
((eq ans "R") "ROUND-NUMBER")
))
(setq pt (getpoint "Specify leader start point: "))
(setq ptlist (cons pt ptlist))
(while (setq pt (getpoint "Specify next point: " pt))
(setq ptlist (cons pt ptlist)
)
)
(setq mtpt (car ptlist))
(setq ptlist (reverse ptlist))
(setq ptlist (apply 'append ptlist))
(setq tmparray
(vlax-make-safearray
vlax-vbdouble
(cons 0 (- (length ptlist) 1))
)
)
(vlax-safearray-fill tmparray ptlist)
(setq tmpvar (vlax-make-variant tmparray))
(setq anno_blk (vla-insertblock
acsp
(vlax-3d-point mtpt)
blk_name
1
1
1
0))
(set-lay adoc "A-ANNO-NOTE" "Continuous" "32")
(vla-put-layer anno_blk "A-ANNO-NOTE")
(setq atts (vlax-invoke anno_blk 'Getattributes))
(foreach at atts
(if (eq (vlax-get at 'Tagstring) "NUMBER")
(progn
(vlax-put at 'Textstring nmb)
(vla-update at))))
(setq lead (vla-addleader acsp tmpvar anno_blk aclinewitharrow)) ;change by suit
(vla-put-arrowheadsize lead 0.0625) ;change by suit
(vla-update lead)
(vlax-release-object lead)
(vla-regen adoc acactiveviewport)
(setvar "CLAYER" oclr)
(setvar "ORTHOMODE" otm)
(setvar "EXPERT" oexp)
(vla-endundomark adoc)
(princ)
)
BCrouse
2005-10-28, 08:18 PM
Fixo,
Thank you very much for the beginning part of the idea. When I run the lisp. It comes up with an Automation Error and Filer error. It will not let me choose an end point.
Brad
Fixo,
Thank you very much for the beginning part of the idea. When I run the lisp. It comes up with an Automation Error and Filer error. It will not let me choose an end point.
Brad
Hi Brad
I slightly edited routine possibly now it will work for you
See attachment
(Tested in A2005 only)
Thank you
f.
BCrouse
2005-10-28, 11:11 PM
Hi Brad
I slightly edited routine possibly now it will work for you
See attachment
(Tested in A2005 only)
Thank you
f.
Fixo,
I am getting and automatiion error: Undefined linetype! Can you please look at
I think it is at Line 11 and Line 117 and 118.
I would fix it but I don't know how.
Thank you,
Brad
Fixo,
I am getting and automatiion error: Undefined linetype! Can you please look at
I think it is at Line 11 and Line 117 and 118.
I would fix it but I don't know how.
Thank you,
Brad
Hi Brad
I don't know why this not work for you
I loaded this routine into all your drawings many times and always
it work fine for me
Ok I edited this routine a lot and added error traping
but this idea don't like to me
I think here need another way with calculation of intersection points
between leader and block and than redraw there are on normal location
(differently for all block types: square, round and triangle)
I'm not a math and I don't know how it will be done
Thank you
f.
CAB2k
2005-10-29, 04:23 PM
I took your second lisp & added an error check if the block was not in the drawing.
This adds the ".DWG" to the block name & then checks to see if it exist.
Also the block names are changed as they did not match those Brad posted.
Routine works for me although it leader & scale may need some work.
I took your second lisp & added an error check if the block was not in the drawing.
This adds the ".DWG" to the block name & then checks to see if it exist.
Also the block names are changed as they did not match those Brad posted.
Routine works for me although it leader & scale may need some work.
Thanks for support CAB
I will test your program tomorrow, today I very busy on another work
and I would wait flashback from our Brad
f.
BCrouse
2005-10-31, 03:34 PM
Hi Brad
I don't know why this not work for you
I loaded this routine into all your drawings many times and always
it work fine for me
Ok I edited this routine a lot and added error traping
but this idea don't like to me
I think here need another way with calculation of intersection points
between leader and block and than redraw there are on normal location
(differently for all block types: square, round and triangle)
I'm not a math and I don't know how it will be done
Thank you
f.
Thank you very much. I got it to work. Just one more thing to ask you. Can you change the bylayer color to cyan?
Than you,
Brad
Thank you very much. I got it to work. Just one more thing to ask you. Can you change the bylayer color to cyan?
Than you,
Brad
Hi Brad
Try edited version
Thank you
f.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.