Have you changed ATTREQ to 0? If so, Why?
(Defun c:mscale()
;scalebar
(COMMAND "_layer" "_m" "scale" "_c" "7" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1))
(setq dt1 (getpoint "\n insert scale bar (scale bar):"))
(command "insert" "mscale" dt1 scl1 scl1 "1")
)
(Defun c:mscale()
;scalebar
(COMMAND "_layer" "_m" "scale" "_c" "7" "" "")
(setq scl (getvar "useri1"))
(setq scl1 (* scl 1))
(setq dt1 (getpoint "\n insert scale bar (scale bar):"))
(command "insert" "mscale" dt1 scl1 scl1 "0")
)
OK, I am out.X2
;; Set Attribute Value - Lee Mac
;; Sets the value of the first attribute with the given tag found within the block, if present.
;; blk - [vla] VLA Block Reference Object
;; tag - [str] Attribute TagString
;; val - [str] Attribute Value
;; Returns: [str] Attribute value if successful, else nil.
(defun LM:vl-setattributevalue ( blk tag val )
(setq tag (strcase tag))
(vl-some
'(lambda ( att )
(if (= tag (strcase (vla-get-tagstring att)))
(progn (vla-put-textstring att val) val)
)
)
(vlax-invoke blk 'getattributes)
)
)
...If you took a wee bit of time to try and figure out my last post (http://www.theswamp.org/index.php?topic=48155.msg532276#msg532276), you've been given all the working pieces for what you want.
isam trying to write a lisp code that fiil the tags automatically
hI ronjonp i read your post but i am not good in lisp and can not understand it , can you help me ?
I like using a field so it will update when viewport changes
...
< Lee's function untainted >
(lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
...
...
...
Hi ronjonp i try to change it but i still have problem, can help me?Code - Auto/Visual Lisp: [Select]
;;< .. >
(defun LM:vl-Setattributevalue ( blk tag VAL)
;; the original routine content ... do not edit
)
(defun c:test ( / local_variables)
;; DO YOUR STUFF
;; Call the external routine
(setq result (LM:vl-Setattributevalue blkval tagval VALval) )
;; DO YOUR STUFF with result if needed.
)
Here is the block i have already uploaded in previous post
(lm:vl-setattributevalue b "D1" (strcat (rtos (/ scale 50) 2 0)))
(lm:vl-setattributevalue b "D2" (strcat (rtos (/ scale 100) 2 0)))
(lm:vl-setattributevalue b "D3" (strcat (rtos (/ scale 50) 2 0)))
(lm:vl-setattributevalue b "D4" (strcat (rtos (* (/ scale 50) 2) 2 0)))
(lm:vl-setattributevalue b "D5" (strcat (rtos (* (/ scale 50) 3) 2 0)))
(lm:vl-setattributevalue b "D6" (strcat (rtos (* (/ scale 50) 4) 2 0)))
(lm:vl-setattributevalue b "D7" (strcat (rtos (/ scale 10) 2 0)))
(lm:vl-setattributevalue b "SCALE" (strcat (rtos scale 2 0)))
I change the maths and works
< .. >
Thanks :-D
(cons "D2" (strcat (rtos (/ scale 100) 2 1)))
Here is an errorCode - Auto/Visual Lisp: [Select]
[CHECKING TEXT <Untitled-0> loading...]
..
; error: malformed list on input
; Check done.
Kerry is it possible to add a filter and when the scale is
50,150,250,350,450,650,...... then use this math for D2Code: [Select](cons "D2" (strcat (rtos (/ scale 100) 2 1)))
(lm:vl-setattributevalue b "D2" (strcat (rtos (/ scl 100) 2 1)))
(lm:vl-setattributevalue b "D1" (strcat (rtos (/ scl 50) 2 0)))
;(lm:vl-setattributevalue b "D2" (strcat (rtos (/ scl 100) 2 0)))
(if (vl-position scl (list 50 150 250 350 450 650))
(cons "D2" (strcat (rtos (/ scl 100.) 2 1)))
(cons "D2" (strcat (rtos (/ scl 100) 2 0)))
)
(lm:vl-setattributevalue b "D3" (strcat (rtos (/ scl 50) 2 0)))
(lm:vl-setattributevalue b "D4" (strcat (rtos (* (/ scl 50) 2) 2 0)))
(lm:vl-setattributevalue b "D5" (strcat (rtos (* (/ scl 50) 3) 2 0)))
(lm:vl-setattributevalue b "D6" (strcat (rtos (* (/ scl 50) 4) 2 0)))
(lm:vl-setattributevalue b "D7" (strcat (rtos (/ scl 10) 2 0)))
(lm:vl-setattributevalue b "SCALE" (strcat (rtos scl 2 0)))
(setvar 'attreq 1)
)
)
(princ)
;;;; Concept code : kdub@theSwamp Nov2014
(defun c:test3a (/ b bname p scale TagData ) ;scalebar
(if (and (setq scale (getint "\nEnter scale to use: "))
(setq p (getpoint "\nSelect insert point for scale bar:"))
(setq bname (findfile "test.dwg"))
)
(progn (command "_layer" "_m" "scale" "_c" "7" "" "")
(setvar 'attreq 0)
(command _"insert" bname p scale scale "0")
(setq b (vlax-ename->vla-object (entlast)))
(setq TagData (list (cons "D1" (strcat (rtos (/ scale 50) 2 0)))
(if (= 50 (rem scale 100))
;; (vl-position scale (list 50 150 250 350 450 650))
(cons "D2" (strcat (rtos (/ scale 100.) 2 1)))
(cons "D2" (strcat (rtos (/ scale 100) 2 0)))
)
(cons "D3" (strcat (rtos (/ scale 50) 2 0)))
(cons "D4" (strcat (rtos (* (/ scale 50) 2) 2 0)))
(cons "D5" (strcat (rtos (* (/ scale 50) 3) 2 0)))
(cons "D6" (strcat (rtos (* (/ scale 50) 4) 2 0)))
(cons "D7" (strcat (rtos (/ scale 10) 2 0)))
(cons "SCALE" (strcat (rtos scale 2 0)))
)
)
(kdub:setattributes b TagData)
(setvar 'attreq 1)
)
)
)
(princ)
< .. >
This code is not filling the tags in my Autocad 2010 !!
Where i can find the kdub:setattributes function ?
can you post it ?