Author Topic: fill scalebar tags  (Read 12522 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: fill scalebar tags
« Reply #45 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 ?



« Last Edit: November 10, 2014, 03:42:16 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #46 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.  
« Last Edit: November 10, 2014, 03:03:01 AM by Topographer »

pedroantonio

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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: fill scalebar tags
« Reply #48 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
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

pedroantonio

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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: fill scalebar tags
« Reply #50 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.  
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

pedroantonio

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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: fill scalebar tags
« Reply #52 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,
« Last Edit: November 10, 2014, 05:05:59 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #53 on: November 10, 2014, 05:21:41 AM »
Where i can find the kdub:setattributes function ?

can you post it ?

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #54 on: November 10, 2014, 05:23:21 AM »
sorry i find it

pedroantonio

  • Guest
Re: fill scalebar tags
« Reply #55 on: November 10, 2014, 05:36:32 AM »
Thank you Kerry.The code works fine now    :lmao:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: fill scalebar tags
« Reply #56 on: November 10, 2014, 06:26:56 AM »
Where i can find the kdub:setattributes function ?

can you post it ?

Yes.  :|
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.