TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: pedroantonio on November 01, 2014, 12:02:28 PM

Title: fill scalebar tags
Post by: pedroantonio on November 01, 2014, 12:02:28 PM
Hi ,I use an attribiute scalebar for my drawings.Is it possible to scale it and fill the tags automaticaly ?

to set the scale for all my blocks i use this code

Code - Auto/Visual Lisp: [Select]
  1. ( DEFUN C:SETSC ()
  2.     (SETQ CURSC (getvar "useri1" ))
  3.     (princ "the scale is 1:")(princ cursc)
  4.     (setq newsc (getint "\nNew scale  1:"))
  5.     (setvar "useri1" newsc)
  6.       (setq a1 (getvar "useri1"))
  7.     ; (setvar "ltscale" (* a1 0.005))
  8.     (princ "\n The scale is  1:")(princ newsc)(princ)
  9. )
  10.  

for the insert and scale i use this lisp code
Code - Auto/Visual Lisp: [Select]
  1. (Defun c:mscale()
  2. ;scalebar
  3. (COMMAND "_layer" "_m" "scale" "_c" "7" "" "")
  4. (setq scl (getvar "useri1"))
  5.  (setq scl1 (* scl 1))
  6.  (setq dt1 (getpoint "\n insert scale bar (scale bar):"))
  7.  (command "insert" "mscale" dt1 scl1 scl1 "0")
  8. )
  9.  

Any ideas  ?

Thanks
Title: Re: fill scalebar tags
Post by: ronjonp on November 01, 2014, 02:18:16 PM
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site%3Atheswamp.org%20fill%20in%20attributes
Title: Re: fill scalebar tags
Post by: pedroantonio on November 02, 2014, 02:20:50 AM
D1 = scale/50
D0 = 0
D2 = scale/100
D3 = scale/50
D4 = (scale/50) X 2
D5 = (scale/50) X 3
D6 =(scale/50) X 4
D7 =scale/10
SCALE = scale

Any other ideas ?
Title: Re: fill scalebar tags
Post by: roy_043 on November 03, 2014, 04:32:44 AM
Have you changed ATTREQ to 0? If so, Why?
Title: Re: fill scalebar tags
Post by: pedroantonio on November 03, 2014, 05:42:21 AM
hi roy_043
Quote
Have you changed ATTREQ to 0? If so, Why?

I can not understand your question !! What do you mean with  ATTREQ to 0

if you are talking abour D0  always must be 0
Title: Re: fill scalebar tags
Post by: Tharwat on November 03, 2014, 07:02:30 AM
ATTREQ is system variable .

Have a look here .
http://docs.autodesk.com/ACD/2011/ENU/filesACR/WS1a9193826455f5ffa23ce210c4a30acaf-5107.htm (http://docs.autodesk.com/ACD/2011/ENU/filesACR/WS1a9193826455f5ffa23ce210c4a30acaf-5107.htm)
Title: Re: fill scalebar tags
Post by: pedroantonio on November 03, 2014, 09:28:00 AM
Ok i understand

I change my code to this

Code: [Select]
(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")
)

I want to ask two things

1) I have a rotation problem after insert the block (look the test1.dwg)
2) is it possible to fill all tags automatically through lisp
Title: Re: fill scalebar tags
Post by: pedroantonio on November 03, 2014, 09:33:13 AM
with  the previeows code i don't have rotation problems !!! and i see no diferense

Code: [Select]
(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")
)
 
Title: Re: fill scalebar tags
Post by: ronjonp on November 03, 2014, 09:48:22 AM
Try this block.
Title: Re: fill scalebar tags
Post by: pedroantonio on November 03, 2014, 09:51:29 AM
can you save it as autocad 2010 ?

Thanks
Title: Re: fill scalebar tags
Post by: roy_043 on November 03, 2014, 10:06:16 AM
OK, I am out.
Title: Re: fill scalebar tags
Post by: pedroantonio on November 03, 2014, 04:35:59 PM
 is it possible to fill all tags automatically through lisp?
Title: Re: fill scalebar tags
Post by: ronjonp on November 03, 2014, 04:57:16 PM

Code - Auto/Visual Lisp: [Select]
  1. (defun c:mscale (/ b p scl)               ;scalebar
  2.   (if (and (setq scl (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  4.       )
  5.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  6.            (setvar 'attreq 0)
  7.            (command "insert" "mscale" p scl scl "0")
  8.            (setq b (vlax-ename->vla-object (entlast)))
  9.            ;; http://www.lee-mac.com/attributefunctions.html#vlsetattributevalue
  10.            ;; Apply the function LM:vl-setattributevalue to appropriate tags in block 'B'
  11.            (setvar 'attreq 1)
  12.     )
  13.   )
  14.   (princ)
  15. )

OK, I am out.
X2
Title: Re: fill scalebar tags
Post by: pedroantonio on November 03, 2014, 05:43:20 PM
You mean this ?

Code: [Select]
;; 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)
    )
)
Title: Re: fill scalebar tags
Post by: pedroantonio on November 04, 2014, 04:19:38 AM
I try this but something is going wrong !!!  :-o

Code - Auto/Visual Lisp: [Select]
  1. (Defun c:test()
  2. ;scalebar
  3. (COMMAND "_layer" "_m" "scale" "_c" "7" "" "")
  4. (setq scl (getvar "useri1"))
  5.  (setq scl1 (* scl 1))
  6.   (setq scale (vla-get-customscale (vlax-ename->vla-object ent)))
  7.   (setq scale (strcat scl1))
  8.   (setq d1 (strcat (rtos (/ 50 scl1) 2 2)))
  9.   (setq d2 (strcat (rtos (/ 100 scl1) 2 2)))
  10.   (setq d3 (strcat (rtos (/ 50 scl1) 2 2) "m"))
  11.   (setq d4 (strcat (rtos (* 2 (/ 50 scl1)) 2 2)))
  12.   (setq d5 (strcat (rtos (* 3 (/ 50 scl1)) 2 2)))
  13.   (setq d6 (strcat (rtos (/ 10 scl1) 2 2)))
  14.  (setq dt1 (getpoint "\n insert scale bar (scale bar):"))
  15.  (command "insert" "test" dt1 scl1 scl1  d1 d2 d3 d4 d5 d6 d7 "0")
  16. )
  17.  

Can anyone help?

Thanks
Title: Re: fill scalebar tags
Post by: ChrisCarlson on November 04, 2014, 08:16:55 AM
I'm confused, why not save time and energy by making a scale block with visibility states? This seems quite slower than inserting a block and changing state. Your insert command also seems weird

Code - Auto/Visual Lisp: [Select]
  1. (command "mscale"  "test" "_S" 1.0 "_R" 0.0 "_non" dt1)

 will bring it in at a scale factor 1, rotation 0 degrees and point dt1. D1 through D6 do not belong in the insert line.

What is the actual intent of D1 through D6?
Title: Re: fill scalebar tags
Post by: pedroantonio on November 04, 2014, 10:08:46 AM
hi  ChrisCarlson

Cabn you help me with the code ?

 isam trying to write a lisp code  that fiil the  tags automatically
Title: Re: fill scalebar tags
Post by: Slim© on November 04, 2014, 10:15:00 AM
Check THIS thread... (http://www.theswamp.org/index.php?topic=1274.msg18935#msg18935) 
Title: Re: fill scalebar tags
Post by: ronjonp on November 04, 2014, 11:02:24 AM
...
 isam trying to write a lisp code  that fiil the  tags automatically
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.
Title: Re: fill scalebar tags
Post by: pedroantonio on November 04, 2014, 11:24:10 AM
hI ronjonp i read your post but i am not good in lisp and can not understand it , can you help me ?
Title: Re: fill scalebar tags
Post by: ronjonp on November 04, 2014, 12:02:01 PM
hI ronjonp i read your post but i am not good in lisp and can not understand it , can you help me ?


I haven't gotten the impression you are trying to understand (http://www.theswamp.org/index.php?topic=47405.msg524267#msg524267) it  :| . The next step is to provide a working solution which I'm not going to do ... sorry.
Title: Re: fill scalebar tags
Post by: pedroantonio on November 04, 2014, 03:35:24 PM
I try to use ronjonp advise but i still have problem

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ b p scl)               ;scalebar
  2.   (if (and (setq scl (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  4.       )
  5.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  6.            (setvar 'attreq 0)
  7.            (command "insert" "test" p scl scl "0")
  8.            (setq b (vlax-ename->vla-object (entlast)))
  9.            ;; http://www.lee-mac.com/attributefunctions.html#vlsetattributevalue
  10.            ;; Apply the function LM:vl-setattributevalue to appropriate tags in block 'B'
  11.     (foreach att (vlax-invoke b 'getattributes)
  12.   (setq scale (strcat scl1))
  13.   (setq d1 (strcat (rtos (/ 50 scl1) 2 2)))
  14.   (setq d2 (strcat (rtos (/ 100 scl1) 2 2)))
  15.   (setq d3 (strcat (rtos (/ 50 scl1) 2 2)))
  16.   (setq d4 (strcat (rtos (*(/ 50 scl1) 2) 2 2)))
  17.   (setq d5 (strcat (rtos (*(/ 50 scl1) 3) 2 2)))
  18.   (setq d6 (strcat (rtos (/ 10 scl1) 2 2)))
  19.         (if (setq itm (assoc (vla-get-tagstring att) d1 d2 d3 d4 d5 d6 d7))
  20.             (vla-put-textstring att (cdr itm))
  21.         )
  22.     )
  23.            (setvar 'attreq 1)
  24.     )
  25.   )
  26.   (princ)
  27. )
  28.  

Any ideas ?

Thanks
Title: Re: fill scalebar tags
Post by: pedroantonio on November 05, 2014, 03:18:17 AM
I am comfiused  :-o and i need help .......

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ b p scl d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  2.   (if (and (setq scl (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  4.       )
  5.     (progn
  6.       (command "_layer" "_m" "scale" "_c" "7" "" "")
  7.       (setvar 'attreq 0)
  8.       (command "insert" "test" p scl scl "0")
  9.       (setq b (vlax-ename->vla-object (entlast)))
  10.       ;; http://www.lee-mac.com/attributefunctions.html#vlsetattributevalue
  11.       ;; Apply the function LM:vl-setattributevalue to appropriate tags in block 'B'
  12.       ;; Set Attribute Value  -  Lee Mac
  13.       ;; Sets the value of the first attribute with the given tag found within the block, if present.
  14.       ;; blk - [vla] VLA Block Reference Object
  15.       ;; tag - [str] Attribute TagString
  16.       ;; val - [str] Attribute Value
  17.       ;; Returns: [str] Attribute value if successful, else nil.
  18.  
  19.       (defun LM:vl-setattributevalue (blk d1 d2 d3 d4 d5 d6 d7 scale)
  20.         (setq scale (strcat scl1))
  21.         (setq d1 (strcat (rtos (/ 50 scl1) 2 2)))
  22.         (setq d2 (strcat (rtos (/ 100 scl1) 2 2)))
  23.         (setq d3 (strcat (rtos (/ 50 scl1) 2 2)))
  24.         (setq d4 (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  25.         (setq d5 (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  26.         (setq d6 (strcat (rtos (/ 10 scl1) 2 2)))
  27.         (vl-some
  28.           '(lambda (test)
  29.              (if (= d1 (strcase (vla-get-tagstring test)))
  30.                (progn (vla-put-textstring test (/ 50 scl1)) (/ 50 scl1))
  31.              )
  32.            )
  33.           (vlax-invoke b 'getattributes)
  34.         )
  35.       )
  36.       (setvar 'attreq 1)
  37.     )
  38.   )
  39.   (princ)
  40. )
  41.  
  42.  

Thanks
Title: Re: fill scalebar tags
Post by: ChrisCarlson on November 05, 2014, 07:43:00 AM
Where does it error? I'd suggest reading up on VLIDE and finding your error.
Title: Re: fill scalebar tags
Post by: Jeff H on November 05, 2014, 01:53:38 PM
I like using a field so it will update when viewport changes

Code - C#: [Select]
  1.        string BarScaleField(double ratio, ObjectId viewPortId)
  2.        {
  3.            return String.Format("%<\\AcExpr ({0}/%<\\AcObjProp Object(%<\\_ObjId {1}>%).CustomScale \\f \"%lu2%qf2816\">%) \\f \"%lu6%zs3\">%", ratio, viewPortId.OldIdPtr.ToString());
  4.        }
  5.  
Title: Re: fill scalebar tags
Post by: pedroantonio on November 06, 2014, 04:01:07 PM
Quote
I like using a field so it will update when viewport changes

I am not using field i don't like them . I use only lisp codes

Something is missing in my code and not fill the tags

 i am trying to write a lisp code  that when i insert the scale bar in model space then  fiil the  tags automatically
I am doing something wrong in this code and i  need some help

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ b p scl d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  2.   (if (and (setq scl (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  4.       )
  5.     (progn
  6.       (command "_layer" "_m" "scale" "_c" "7" "" "")
  7.       (setvar 'attreq 0)
  8.       (command "insert" "test" p scl scl "0")
  9.       (setq b (vlax-ename->vla-object (entlast)))
  10.       ;; http://www.lee-mac.com/attributefunctions.html#vlsetattributevalue
  11.       ;; Apply the function LM:vl-setattributevalue to appropriate tags in block 'B'
  12.       ;; Set Attribute Value  -  Lee Mac
  13.       ;; Sets the value of the first attribute with the given tag found within the block, if present.
  14.       ;; blk - [vla] VLA Block Reference Object
  15.       ;; tag - [str] Attribute TagString
  16.       ;; val - [str] Attribute Value
  17.       ;; Returns: [str] Attribute value if successful, else nil.
  18.  
  19.       (defun LM:vl-setattributevalue (blk d1 d2 d3 d4 d5 d6 d7 scale)
  20.         (setq scale (strcat scl1))
  21.         (setq d1 (strcat (rtos (/ 50 scl1) 2 2)))
  22.         (setq d2 (strcat (rtos (/ 100 scl1) 2 2)))
  23.         (setq d3 (strcat (rtos (/ 50 scl1) 2 2)))
  24.         (setq d4 (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  25.         (setq d5 (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  26.         (setq d6 (strcat (rtos (/ 10 scl1) 2 2)))
  27.         (vl-some
  28.           '(lambda (test)
  29.              (if (= d1 (strcase (vla-get-tagstring test)))
  30.                (progn (vla-put-textstring test (/ 50 scl1)) (/ 50 scl1))
  31.              )
  32.            )
  33.           (vlax-invoke b 'getattributes)
  34.         )
  35.       )
  36.       (setvar 'attreq 1)
  37.     )
  38.   )
  39.   (princ)
  40. )
  41.  

Any ideas ?
Title: Re: fill scalebar tags
Post by: ronjonp on November 06, 2014, 04:13:06 PM
Yer killin me smalls  ;D
Here's a hint:
Code: [Select]
...
< Lee's function untainted >
(lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
...
...
...

& take all the stuff you added out of Lee's function.
Title: Re: fill scalebar tags
Post by: pedroantonio on November 06, 2014, 04:24:46 PM
Hi ronjonp i try to change it but i still have problem, can help me?

Code - Auto/Visual Lisp: [Select]
  1. Code - Auto/Visual Lisp: [Select]
  2. (defun c:test (/ b p scl d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  3.   (if (and (setq scl (getint "\nEnter scale to use: "))
  4.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  5.       )
  6.     (progn
  7.       (command "_layer" "_m" "scale" "_c" "7" "" "")
  8.       (setvar 'attreq 0)
  9.       (command "insert" "test" p scl scl "0")
  10.       (setq b (vlax-ename->vla-object (entlast)))
  11.       ;; http://www.lee-mac.com/attributefunctions.html#vlsetattributevalue
  12.       ;; Apply the function LM:vl-setattributevalue to appropriate tags in block 'B'
  13.       ;; Set Attribute Value  -  Lee Mac
  14.       ;; Sets the value of the first attribute with the given tag found within the block, if present.
  15.       ;; blk - [vla] VLA Block Reference Object
  16.       ;; tag - [str] Attribute TagString
  17.       ;; val - [str] Attribute Value
  18.       ;; Returns: [str] Attribute value if successful, else nil.
  19.     (lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
  20.    (lm:vl-setattributevalue b "d2" (strcat (rtos (/ 100 scl1) 2 2)))
  21.    (lm:vl-setattributevalue b "d3" (strcat (rtos (/ 50 scl1) 2 2)))
  22.    (lm:vl-setattributevalue b "d4" (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  23.    (lm:vl-setattributevalue b "d5" (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  24.    (lm:vl-setattributevalue b "d6" (strcat (rtos (/ 50 scl1) 2 2)))
  25.     (lm:vl-setattributevalue b "scale" (strcat (scl1) 2 2)))
  26.  
  27.    (vl-some
  28.           '(lambda (test)
  29.              (if (= d1 (strcase (vla-get-tagstring test)))
  30.                (progn (vla-put-textstring test (/ 50 scl1)) (/ 50 scl1))
  31.              )
  32.            )
  33.           (vlax-invoke b 'getattributes)
  34.         )
  35.       )
  36.       (setvar 'attreq 1)
  37.     )
  38.     (princ)
Title: Re: fill scalebar tags
Post by: ChrisCarlson on November 06, 2014, 04:27:57 PM
Well for one, you need to have Lee's sub routine within that lisp file. it will start with (defun lm:vl-setattributevalue
Title: Re: fill scalebar tags
Post by: pedroantonio on November 07, 2014, 05:47:50 PM
I am writting something wrong.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ b p scl d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  2.   (if (and (setq scl (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  4.       )
  5.     (progn
  6.       (command "_layer" "_m" "scale" "_c" "7" "" "")
  7.       (setvar 'attreq 0)
  8.       (command "insert" "test" p scl scl "0")
  9.       (setq b (vlax-ename->vla-object (entlast)))
  10.       ;; http://www.lee-mac.com/attributefunctions.html#vlsetattributevalue
  11.       ;; Apply the function LM:vl-setattributevalue to appropriate tags in block 'B'
  12.       ;; Set Attribute Value  -  Lee Mac
  13.       ;; Sets the value of the first attribute with the given tag found within the block, if present.
  14.       ;; blk - [vla] VLA Block Reference Object
  15.       ;; tag - [str] Attribute TagString
  16.       ;; val - [str] Attribute Value
  17.       ;; Returns: [str] Attribute value if successful, else nil.
  18.   (defun lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
  19.    ("d2" (strcat (rtos (/ 100 scl1) 2 2)))
  20.    ("d3" (strcat (rtos (/ 50 scl1) 2 2)))
  21.    ("d4" (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  22.    ("d5" (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  23.    ("d6" (strcat (rtos (/ 50 scl1) 2 2)))
  24.     ("scale" (strcat (scl1) 2 2)))
  25.  
  26.    (vl-some
  27.           '(lambda (test)
  28.              (if (= d1 (strcase (vla-get-tagstring test)))
  29.                (progn (vla-put-textstring test (/ 50 scl1)) (/ 50 scl1))
  30.              )
  31.            )
  32.           (vlax-invoke b 'getattributes)
  33.         )
  34.       )
  35.       (setvar 'attreq 1)
  36.     )
  37.     (princ)

Can any one help ?
Title: Re: fill scalebar tags
Post by: ronjonp on November 07, 2014, 10:22:53 PM
You were closer on your previous attempt.  Don't change anything inside Lee's function.
Title: Re: fill scalebar tags
Post by: Kerry on November 08, 2014, 12:14:29 AM
Hi ronjonp i try to change it but i still have problem, can help me?

Code - Auto/Visual Lisp: [Select]
  1. ;;< .. >
  2.  

TRY A STRUCTURE LIKE THIS :
Code - Auto/Visual Lisp: [Select]
  1. (defun LM:vl-Setattributevalue ( blk tag VAL)
  2.  
  3.         ;; the original routine content ... do not edit
  4.  
  5.  
  6. )
  7.  
  8. (defun c:test ( / local_variables)
  9.  
  10.         ;; DO YOUR STUFF
  11.  
  12.   ;; Call the external routine
  13.  
  14.   (setq result (LM:vl-Setattributevalue  blkval tagval VALval) )
  15.  
  16.   ;; DO YOUR STUFF with result if needed.
  17. )
Title: Re: fill scalebar tags
Post by: pedroantonio on November 08, 2014, 03:35:45 AM
Hi Kerry , I am confused. I am not good in lisp , i am trying to learn and i can not understand more things.

Quote
(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.
)

How to do this , and a think tha here in my code is a lot of mistakes !!!

Code - Auto/Visual Lisp: [Select]
  1.   (defun lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
  2.    ("d2" (strcat (rtos (/ 100 scl1) 2 2)))
  3.    ("d3" (strcat (rtos (/ 50 scl1) 2 2)))
  4.    ("d4" (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  5.    ("d5" (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  6.    ("d6" (strcat (rtos (/ 50 scl1) 2 2)))
  7.     ("scale" (strcat (scl1) 2 2)))
  8.  

Thanks
Title: Re: fill scalebar tags
Post by: Kerry on November 08, 2014, 04:01:41 AM
You just don't want to read what people are saying, do you ??

DO NOT REDEFINE THE lm:vl-setattributevalue  code.

use something like this in your routine

Code - Auto/Visual Lisp: [Select]
  1.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  2.            (setvar 'attreq 0)
  3.            (command "insert" "test" p scl scl "0")
  4.            (setq b (vlax-ename->vla-object (entlast)))
  5.  
  6.            ( lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
  7.            ( lm:vl-setattributevalue b "d2" (strcat (rtos (/ 100 scl1) 2 2)))
  8.            ( lm:vl-setattributevalue b "d3" (strcat (rtos (/ 50 scl1) 2 2)))
  9.            ( lm:vl-setattributevalue b "d4" (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  10.            ( lm:vl-setattributevalue b "d5" (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  11.            ( lm:vl-setattributevalue b "d6" (strcat (rtos (/ 50 scl1) 2 2)))
  12.            ( lm:vl-setattributevalue b "scale" (strcat (scl1) 2 2))
  13.     )
  14.  
  15.  


I haven't tried to test your code because you didn't bother to supply the block for people to test with ... and I'm not inclined to make a block.
Title: Re: fill scalebar tags
Post by: pedroantonio on November 08, 2014, 04:18:34 AM
Here is the block i have already uploaded in previous post
Title: Re: fill scalebar tags
Post by: pedroantonio on November 08, 2014, 04:28:38 AM
I try this but still not update the scalebar ....

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ b p scl d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  2.   (if (and (setq scl (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  4.       )
  5.  (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  6.            (setvar 'attreq 0)
  7.            (command "insert" "test" p scl scl "0")
  8.            (setq b (vlax-ename->vla-object (entlast)))
  9.            ( lm:vl-setattributevalue b "d1" (strcat (rtos (/ 50 scl1) 2 2)))
  10.            ( lm:vl-setattributevalue b "d2" (strcat (rtos (/ 100 scl1) 2 2)))
  11.            ( lm:vl-setattributevalue b "d3" (strcat (rtos (/ 50 scl1) 2 2)))
  12.            ( lm:vl-setattributevalue b "d4" (strcat (rtos (* (/ 50 scl1) 2) 2 2)))
  13.            ( lm:vl-setattributevalue b "d5" (strcat (rtos (* (/ 50 scl1) 3) 2 2)))
  14.            ( lm:vl-setattributevalue b "d6" (strcat (rtos (/ 50 scl1) 2 2)))
  15.            ( lm:vl-setattributevalue b "d7" (strcat (rtos (/ 10 scl1) 2 2)))
  16.            ( lm:vl-setattributevalue b "scale" (strcat (scl1) 2 2))
  17.     )
  18.  
  19.           '(lambda (test)
  20.              (if (= d1 (strcase (vla-get-tagstring test)))
  21.                (progn (vla-put-textstring test (/ 50 scl1)) (/ 50 scl1))
  22.              )
  23.            )
  24.           (vlax-invoke b 'getattributes)
  25.         )
  26.       )
  27.       (setvar 'attreq 1)
  28.     )
  29.     (princ)
  30.  

Title: Re: fill scalebar tags
Post by: Kerry on November 08, 2014, 05:58:17 AM
Here is the block i have already uploaded in previous post

Ooops , sorry, I missed the first page of the thread ... my bad  :oops:

I'll have a look at it in the morning if no-one else has resolved the issue.

Regards,
Title: Re: fill scalebar tags
Post by: Ketxu on November 08, 2014, 06:03:20 AM
Code - Auto/Visual Lisp: [Select]
  1. OOOPS ^^
  2. ;;PLEASE DO NOT CHANGE THIS FROM HERE <=============
  3.  
  4. ;; Set Attribute Value  -  Lee Mac
  5. ;; Sets the value of the first attribute with the given tag found within the block, if present.
  6. ;; blk - [vla] VLA Block Reference Object
  7. ;; tag - [str] Attribute TagString
  8. ;; val - [str] Attribute Value
  9. ;; Returns: [str] Attribute value if successful, else nil.
  10.  
  11. (defun LM:vl-setattributevalue ( blk tag val )
  12.     (setq tag (strcase tag))
  13.     (vl-some
  14.        '(lambda ( att )
  15.             (if (= tag (strcase (vla-get-tagstring att)))
  16.                 (progn (vla-put-textstring att val) val)
  17.             )
  18.         )
  19.         (vlax-invoke blk 'getattributes)
  20.     )
  21. )
  22.  
  23. ;;;;;; =========================================> TO HERE
  24.  
  25.  
  26.  
  27. (defun c:test (/ b p scl d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  28.   (if (and (setq scl (getint "\nEnter scale to use: "))
  29.            (setq p (getpoint "\n insert scale bar (scale bar):"))
  30.       )
  31.  (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  32.            (setvar 'attreq 0)
  33.            (command "insert" "test" p scl scl "0")
  34.            (setq b (vlax-ename->vla-object (entlast)))
  35.                    ;Now just use lm:vl-setattributevalue funtion was defined before
  36.            ( lm:vl-setattributevalue b "D1" (strcat (rtos (/ 50 scl) 2 2)))                     ;Where scl1 ? You did not specify it. I changed to scl
  37.            ( lm:vl-setattributevalue b "D2" (strcat (rtos (/ 100 scl) 2 2)))
  38.            ( lm:vl-setattributevalue b "D3" (strcat (rtos (/ 50 scl) 2 2)))
  39.            ( lm:vl-setattributevalue b "D4" (strcat (rtos (* (/ 50 scl) 2) 2 2)))
  40.            ( lm:vl-setattributevalue b "D5" (strcat (rtos (* (/ 50 scl) 3) 2 2)))
  41.            ( lm:vl-setattributevalue b "D6" (strcat (rtos (/ 50 scl) 2 2)))
  42.            ( lm:vl-setattributevalue b "D7" (strcat (rtos (/ 10 scl) 2 2)))
  43.            ( lm:vl-setattributevalue b "SCALE" (strcat (rtos scl 2 2)))
  44.     )
  45. )
  46.  (princ)
  47.  )
Title: Re: fill scalebar tags
Post by: Kerry on November 08, 2014, 06:58:05 AM

This works for me:

Code - Auto/Visual Lisp: [Select]
  1.  
  2.  
  3. (defun c:test (/ b bname p scale)            ;scalebar
  4.   (if (and (setq scale (getint "\nEnter scale to use: "))
  5.            (setq p (getpoint "\nSelect insert point for scale bar:"))
  6.            (setq bname (findfile "test.dwg"))
  7.       )
  8.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  9.            (setvar 'attreq 0)
  10.            (command "insert" bname p scale scale "0")
  11.            (setq b (vlax-ename->vla-object (entlast)))
  12.            (lm:vl-setattributevalue b "D1" (strcat (rtos (/ 50 scale) 2 2)))
  13.            (lm:vl-setattributevalue b "D2" (strcat (rtos (/ 100 scale) 2 2)))
  14.            (lm:vl-setattributevalue b "D3" (strcat (rtos (/ 50 scale) 2 2)))
  15.            (lm:vl-setattributevalue b "D4" (strcat (rtos (* (/ 50 scale) 2) 2 2)))
  16.            (lm:vl-setattributevalue b "D5" (strcat (rtos (* (/ 50 scale) 3) 2 2)))
  17.            (lm:vl-setattributevalue b "D6" (strcat (rtos (/ 50 scale) 2 2)))
  18.            (lm:vl-setattributevalue b "D7" (strcat (rtos (/ 10 scale) 2 2)))
  19.            (lm:vl-setattributevalue b "SCALE" (strcat (rtos scale 2 2)))
  20.            (setvar 'attreq 1)
  21.     )
  22.   )
  23. )
  24.  
  25.  
  26.  

Your Math could do with some modifications though :)

Please compare my code thoroughly with yours.
Personally I use a routine that takes the blockID and a association list of all the <key . value > pairs.
... since you are using Lee's stuff ; similar to http://www.lee-mac.com/attributefunctions.html#alsetattributevaluesit
Title: Re: fill scalebar tags
Post by: pedroantonio on November 08, 2014, 09:38:47 AM
Hi  Kerry I change the code but give me only 0.00 and it is very slow

Code - Auto/Visual Lisp: [Select]
  1. ;; Set Attribute Value  -  Lee Mac
  2. ;; Sets the value of the first attribute with the given tag found within the block, if present.
  3. ;; blk - [vla] VLA Block Reference Object
  4. ;; tag - [str] Attribute TagString
  5. ;; val - [str] Attribute Value
  6. ;; Returns: [str] Attribute value if successful, else nil.
  7.  
  8. (defun LM:vl-setattributevalue ( blk tag val )
  9.     (setq tag (strcase tag))
  10.     (vl-some
  11.        '(lambda ( att )
  12.             (if (= tag (strcase (vla-get-tagstring att)))
  13.                 (progn (vla-put-textstring att val) val)
  14.             )
  15.         )
  16.         (vlax-invoke blk 'getattributes)
  17.     )
  18. )
  19.  
  20. (defun c:test (/ b p d1 d2 d3 d4 d5 d6 d7 scale) ;scalebar
  21.   (if (and (setq scale (getint "\nEnter scale to use: "))
  22.            (setq p (getpoint "\nSelect insert point for scale bar:"))
  23.            (setq bname (findfile "test.dwg"))
  24.       )
  25.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  26.            (setvar 'attreq 0)
  27.            (command "insert" bname p scale scale "0")
  28.            (setq b (vlax-ename->vla-object (entlast)))
  29.            (lm:vl-setattributevalue b "D1" (strcat (rtos (/ 50 scale) 2 2)))
  30.            (lm:vl-setattributevalue b "D2" (strcat (rtos (/ 100 scale) 2 2)))
  31.            (lm:vl-setattributevalue b "D3" (strcat (rtos (/ 50 scale) 2 2)))
  32.            (lm:vl-setattributevalue b "D4" (strcat (rtos (* (/ 50 scale) 2) 2 2)))
  33.            (lm:vl-setattributevalue b "D5" (strcat (rtos (* (/ 50 scale) 3) 2 2)))
  34.            (lm:vl-setattributevalue b "D6" (strcat (rtos (/ 50 scale) 2 2)))
  35.            (lm:vl-setattributevalue b "D7" (strcat (rtos (/ 10 scale) 2 2)))
  36.            (lm:vl-setattributevalue b "SCALE" (strcat (rtos scale 2 0)))
  37.            (setvar 'attreq 1)
  38.     )
  39.   )
  40. )
  41.  
  42.  

Any ideas
Title: Re: fill scalebar tags
Post by: pedroantonio on November 08, 2014, 09:49:29 AM
I change the maths and works

Code: [Select]
(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)))

Thanks  :-D
Title: Re: fill scalebar tags
Post by: Kerry on November 09, 2014, 03:43:53 AM
I change the maths and works

< .. >
Thanks  :-D

You're welcome. Glad to be able to help.
Title: Re: fill scalebar tags
Post by: Kerry on November 09, 2014, 09:27:03 PM
This is one way I'd look at

See if it's any faster ...

Code - Auto/Visual Lisp: [Select]
  1. ;;;------------------------------------------------------------------
  2. ;;;------------------------------------------------------------------
  3. ;;;
  4. ;| KDUB:SetAttributes
  5.     < BlockRef > Object [VLA-OBJECT]
  6.     < DotList   > Dot-list '(("tagstring1" . "textstring1")...) [LIST]
  7.        
  8.         Description: Set attribute values to a block.
  9.    
  10.         Return [Typ]    ==>nil
  11.        
  12.         Remarks:        N/a
  13.         Dependencies:   N/a    
  14. revised kdub 2003 for ac2004|;
  15. ;;;------------------------------------------------------------------
  16. ;;;------------------------------------------------------------------
  17. ;;;
  18.  
  19. (defun kdub:setattributes (blockref dotlist / catchit attval)
  20.   (if (= (type blockref) 'ename)
  21.     (setq blockref (vlax-ename->vla-object blockref))
  22.   )
  23.                                    (vl-catch-all-apply 'vlax-invoke (list blockref 'getattributes))
  24.                             )
  25.       )
  26.     ;; else
  27.     (progn
  28.       (mapcar
  29.         '(lambda (attref)
  30.            (if (setq attval (cdr (assoc (vla-get-tagstring attref) dotlist)))
  31.              (vla-put-textstring attref attval)
  32.            )
  33.          )
  34.         catchit
  35.       )
  36.       (vla-update blockref)
  37.     )
  38.   )
  39.   (princ)
  40. )
  41.  
  42.  

Code - Auto/Visual Lisp: [Select]
  1. ;; kdub@theSwamp Nov2014
  2. (defun c:test-03 (/ b bname p scale)         ;scalebar
  3.   (if (and (setq scale (getint "\nEnter scale to use: "))
  4.            (setq p (getpoint "\nSelect insert point for scale bar:"))
  5.            (setq bname (findfile "test.dwg"))
  6.       )
  7.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  8.            (setvar 'attreq 0)
  9.            (command "insert" bname p scale scale "0")
  10.            (setq b (vlax-ename->vla-object (entlast)))
  11.            (setq TagData (list (cons "D1" (strcat (rtos (/ scale 50.) 2 1)))
  12.                                (cons "D2" (strcat (rtos (/ scale 100.) 2 1)))
  13.                                (cons "D3" (strcat (rtos (/ scale 50.) 2 1)))
  14.                                (cons "D4" (strcat (rtos (* (/ scale 50.) 2) 2 1)))
  15.                                (cons "D5" (strcat (rtos (* (/ scale 50.) 3) 2 1)))
  16.                                (cons "D6" (strcat (rtos (* (/ scale 50.) 4) 2 1)))
  17.                                (cons "D7" (strcat (rtos (/ scale 10.) 2 1)))
  18.                                (cons "SCALE" (strcat (rtos scale 2 0)))
  19.                          )
  20.            )
  21.            (kdub:setattributes b TagData)
  22.            (setvar 'attreq 1)
  23.     )
  24.   )
  25. )
  26.  
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 01:43:40 AM
Here is an error

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test3 (/ b bname p scale)         ;scalebar
  2.   (if (and (setq scale (getint "\nEnter scale to use: "))
  3.            (setq p (getpoint "\nSelect insert point for scale bar:"))
  4.            (setq bname (findfile "test.dwg"))
  5.       )
  6.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  7.            (setvar 'attreq 0)
  8.            (command "insert" bname p scale scale "0")
  9.            (setq b (vlax-ename->vla-object (entlast)))
  10.            (setq TagData (list (cons "D1" (strcat (rtos (/ scale 50) 2 0)))
  11.                                (cons "D2" (strcat (rtos (/ scale 100) 2 0)))
  12.                                (cons "D3" (strcat (rtos (/ scale 50) 2 0))
  13.                                (cons "D4" (strcat (rtos (* (/ scale 50) 2) 2 0)))
  14.                                (cons "D5" (strcat (rtos (* (/ scale 50) 3) 2 0)))
  15.                                (cons "D6" (strcat (rtos (* (/ scale 50) 4) 2 0)))
  16.                                (cons "D7" (strcat (rtos (/ scale 10) 2 0)))
  17.                                (cons "SCALE" (strcat (rtos scale 2 0)))
  18.                          )
  19.            )
  20.            (kdub:setattributes b TagData)
  21.            (setvar 'attreq 1)
  22.     )
  23.   )
  24. )
  25.  

[CHECKING TEXT <Untitled-0> loading...]
..
; error: malformed list on input
; Check done.

Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 01:53:53 AM
Kerry is it possible to add a filter and when the scale is
50,150,250,350,450,650,...... then use this math for D2

Code: [Select]
(cons "D2" (strcat (rtos (/ scale 100) 2 1)))
Title: Re: fill scalebar tags
Post by: Kerry on November 10, 2014, 02:43:11 AM
Here is an error

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test3 (/ b bname p scale)         ;scalebar
  2.  < .. >
  3.  

[CHECKING TEXT <Untitled-0> loading...]
..
; error: malformed list on input
; Check done.

That's because you stuffed up the parenthesis when you edited my code.


Kerry is it possible to add a filter and when the scale is
50,150,250,350,450,650,...... then use this math for D2

Code: [Select]
(cons "D2" (strcat (rtos (/ scale 100) 2 1)))

Yes, options
Code - Auto/Visual Lisp: [Select]
  1. (if (= 50 (rem scale 100.))    
  2.          (cons "D2" (strcat (rtos (/ scale 100.) 2 1)))
  3.          (cons "D2" (strcat (rtos (/ scale 100) 2 0)))
  4. )
  5.  
Code - Auto/Visual Lisp: [Select]
  1. (if (vl-position scale (list 50 150 250 350 450 650))
  2.          (cons "D2" (strcat (rtos (/ scale 100.) 2 1)))
  3.          (cons "D2" (strcat (rtos (/ scale 100) 2 0)))
  4. )
  5.  


I'm wondering why you don't use one decimal place typically.

Why did you remove the decimal place from my multiplication and division calcs ?



Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 02:56:18 AM
something is wrong here

Code - Auto/Visual Lisp: [Select]
  1. (lm:vl-setattributevalue b "D1" (strcat (rtos (/ scl 50) 2 0)))
  2. ;(lm:vl-setattributevalue b "D2" (strcat (rtos (/ scl 100) 2 0)))
  3. (if (vl-position scl (list 50 150 250 350 450 650))
  4.          (cons "D2" (strcat (rtos (/ scl 100.) 2 1)))
  5.          (cons "D2" (strcat (rtos (/ scl 100) 2 0)))
  6. )
  7. (lm:vl-setattributevalue b "D3" (strcat (rtos (/ scl 50) 2 0)))
  8. (lm:vl-setattributevalue b "D4" (strcat (rtos (* (/ scl 50) 2) 2 0)))
  9. (lm:vl-setattributevalue b "D5" (strcat (rtos (* (/ scl 50) 3) 2 0)))
  10. (lm:vl-setattributevalue b "D6" (strcat (rtos (* (/ scl 50) 4) 2 0)))
  11. (lm:vl-setattributevalue b "D7" (strcat (rtos (/ scl 10) 2 0)))
  12. (lm:vl-setattributevalue b "SCALE" (strcat (rtos scl 2 0)))
  13. (setvar 'attreq 1)
  14. )
  15. )
  16.  
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 03:16:45 AM
 Why in D2 gives me 2.0 and not 2.5 for scale 250 ?
I have changes the maths to

Code: [Select]
(lm:vl-setattributevalue b "D2" (strcat (rtos (/ scl 100) 2 1)))
Title: Re: fill scalebar tags
Post by: Kerry on November 10, 2014, 03:40:42 AM

For the fifteenth time , change
(/ scl 100)
to
(/ scl 100. )


When you divide integers the result will be an integer .. rounded

(/ 9 7)   ;-> 1
(/ 5 2 )  ;-> 2
(/ 9. 7 ) ;-> 1.28571
(/ 5. 2 ) ;-> 2.5


http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-E9E70DA9-6048-470D-B899-239B097671D2
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 04:27:11 AM
how to use this ?

Code - Auto/Visual Lisp: [Select]
  1. (if (vl-position scale (list 50 150 250 350 450 650))
  2.          (cons "D2" (strcat (rtos (/ scale 100.) 2 1)))
  3.          (cons "D2" (strcat (rtos (/ scale 100) 2 0)))
  4. )
  5.  
  6.  

is not working

Code: [Select]
(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)
Title: Re: fill scalebar tags
Post by: Kerry on November 10, 2014, 04:36:51 AM

I tested it like this :

Code - Auto/Visual Lisp: [Select]
  1. ;;;; Concept code :  kdub@theSwamp Nov2014
  2. (defun c:test3a (/ b bname p scale TagData )          ;scalebar
  3.   (if (and (setq scale (getint "\nEnter scale to use: "))
  4.            (setq p (getpoint "\nSelect insert point for scale bar:"))
  5.            (setq bname (findfile "test.dwg"))
  6.       )
  7.     (progn (command "_layer" "_m" "scale" "_c" "7" "" "")
  8.            (setvar 'attreq 0)
  9.            (command _"insert" bname p scale scale "0")
  10.            (setq b (vlax-ename->vla-object (entlast)))
  11.            (setq TagData (list (cons "D1" (strcat (rtos (/ scale 50) 2 0)))
  12.                                (if (= 50 (rem scale 100))
  13.                                  ;; (vl-position scale (list 50 150 250 350 450 650))
  14.                                  (cons "D2" (strcat (rtos (/ scale 100.) 2 1)))
  15.                                  (cons "D2" (strcat (rtos (/ scale 100) 2 0)))
  16.                                )
  17.                                (cons "D3" (strcat (rtos (/ scale 50) 2 0)))
  18.                                (cons "D4" (strcat (rtos (* (/ scale 50) 2) 2 0)))
  19.                                (cons "D5" (strcat (rtos (* (/ scale 50) 3) 2 0)))
  20.                                (cons "D6" (strcat (rtos (* (/ scale 50) 4) 2 0)))
  21.                                (cons "D7" (strcat (rtos (/ scale 10) 2 0)))
  22.                                (cons "SCALE" (strcat (rtos scale 2 0)))
  23.                          )
  24.            )
  25.            (kdub:setattributes b TagData)
  26.            (setvar 'attreq 1)
  27.     )
  28.   )
  29. )
  30.  
  31.  
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 04:51:45 AM
Quote
;;;; 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 !!
Title: Re: fill scalebar tags
Post by: Kerry on November 10, 2014, 04:59:30 AM
< .. >
This code is not filling the tags in my Autocad 2010 !!

I don't have ac2010, so can't test.

Did you load the kdub:setattributes function ?
What scale did you use ?
Were there any error messages ?
Was it working previously ?
etc, etc,
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 05:21:41 AM
Where i can find the kdub:setattributes function ?

can you post it ?
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 05:23:21 AM
sorry i find it
Title: Re: fill scalebar tags
Post by: pedroantonio on November 10, 2014, 05:36:32 AM
Thank you Kerry.The code works fine now    :lmao:
Title: Re: fill scalebar tags
Post by: Kerry on November 10, 2014, 06:26:56 AM
Where i can find the kdub:setattributes function ?

can you post it ?

Yes.  :|