Author Topic: fill scalebar tags  (Read 12559 times)

0 Members and 1 Guest are viewing this topic.

ChrisCarlson

  • Guest
Re: fill scalebar tags
« Reply #15 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?

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #16 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

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: fill scalebar tags
« Reply #17 on: November 04, 2014, 10:15:00 AM »
I drink beer and I know things....

ronjonp

  • Needs a day job
  • Posts: 7529
Re: fill scalebar tags
« Reply #18 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, you've been given all the working pieces for what you want.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #19 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 ?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: fill scalebar tags
« Reply #20 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 it  :| . The next step is to provide a working solution which I'm not going to do ... sorry.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #21 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

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #22 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

ChrisCarlson

  • Guest
Re: fill scalebar tags
« Reply #23 on: November 05, 2014, 07:43:00 AM »
Where does it error? I'd suggest reading up on VLIDE and finding your error.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: fill scalebar tags
« Reply #24 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.  

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #25 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 ?

ronjonp

  • Needs a day job
  • Posts: 7529
Re: fill scalebar tags
« Reply #26 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.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #27 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)

ChrisCarlson

  • Guest
Re: fill scalebar tags
« Reply #28 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

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #29 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 ?