Author Topic: Dimscale display  (Read 8128 times)

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
Re: Dimscale display
« Reply #15 on: January 28, 2009, 04:11:14 PM »
You pretty much got the best right there.

dustinthiesse

  • Guest
Re: Dimscale display
« Reply #16 on: January 28, 2009, 04:19:59 PM »
this is the site I'm using (in addition to swamp)
http://www.afralisp.net/index.htm

does anybody recommend any others?

That one is pretty comprehensive and a very good resource.
Another that I found pretty helpful when I started learning lisp was
http://www.jefferypsanders.com/autolisptut.html

deegeecees

  • Guest
Re: Dimscale display
« Reply #17 on: January 28, 2009, 04:23:08 PM »
The Garden Path is a good tutorial/resource too, available in the Developer Help section of your installed AutoCad application, as well as the Developer Help section itself.

Luke

  • Guest
Re: Dimscale display
« Reply #18 on: January 30, 2009, 08:43:36 AM »
Still struggling w/ this...

I've got the defun and I've got the alert but can't understand the IF...

If dimscale = # then display alert...

but I can not just say (= dimscale 20) right?... cause = is for numbers and dimscale is a system variable?


dustinthiesse

  • Guest
Re: Dimscale display
« Reply #19 on: January 30, 2009, 09:27:21 AM »
Still struggling w/ this...

I've got the defun and I've got the alert but can't understand the IF...

If dimscale = # then display alert...

but I can not just say (= dimscale 20) right?... cause = is for numbers and dimscale is a system variable?

use getvar
Code: [Select]
(if (= (getvar 'dimscale) ##)) (alert........))

Luke

  • Guest
Re: Dimscale display
« Reply #20 on: January 30, 2009, 10:25:47 AM »
Thanks d-unit!

So here is where I am at now...
Code: [Select]
(defun c:dimscale_Display ()
(IF    (= (getvar 'dimscale) 1) (alert "12\"  =  1'"))
        (= (getvar 'dimscale) 2) (alert "6\"  =  1'")
        (= (getvar 'dimscale) 3) (alert "4\"  =  1'")
        (= (getvar 'dimscale) 4) (alert "3\"  =  1'")
        (= (getvar 'dimscale) 6) (alert "2\"  =  1'")
        (= (getvar 'dimscale) 8) (alert "1-1/2\"  =  1'")
        (= (getvar 'dimscale) 12) (alert "1\"  =  1'")
        (= (getvar 'dimscale) 16) (alert "3/4\"  =  1'")
        (= (getvar 'dimscale) 24) (alert "1/2\"  =  1'")
        (= (getvar 'dimscale) 32) (alert "3/8\"  =  1'")
        (= (getvar 'dimscale) 48) (alert "1/4\"  =  1'")
        (= (getvar 'dimscale) 64) (alert "3/16\"  =  1'")
        (= (getvar 'dimscale) 96) (alert "1/8\"  =  1'")
        (= (getvar 'dimscale) 128) (alert "3/32\"  =  1'")
        (= (getvar 'dimscale) 192) (alert "1/16\"  =  1'")
        (= (getvar 'dimscale) 384) (alert "1/32\"  =  1'")
        (t (alert "SCALE IS NOT STANDARD"))
)

as of right now this is giving every alert regardless of dimscale?

I've tried as cond instead of if but same results.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimscale display
« Reply #21 on: January 30, 2009, 10:44:27 AM »
Code: [Select]
(defun c:dimscale_Display ( / msg)
  (if
    (setq msg (assoc (getvar 'dimscale)
                     '((1 "12\"  =  1'")
                       (2 "6\"  =  1'")
                       (3 "4\"  =  1'")
                       (4 "3\"  =  1'")
                       (6 "2\"  =  1'")
                       (8 "1-1/2\"  =  1'")
                       (12 "1\"  =  1'")
                       (16 "3/4\"  =  1'")
                       (24 "1/2\"  =  1'")
                       (32 "3/8\"  =  1'")
                       (48 "1/4\"  =  1'")
                       (64 "3/16\"  =  1'")
                       (96 "1/8\"  =  1'")
                       (128 "3/32\"  =  1'")
                       (192 "1/16\"  =  1'")
                       (384 "1/32\"  =  1'")
                       )))
    (alert (cadr msg))
    (alert "SCALE IS NOT STANDARD")
  )
  (princ)
  )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Dimscale display
« Reply #22 on: January 30, 2009, 10:49:30 AM »
Didn't validate your data, but functionally this should work:

Code: [Select]
(defun c:DDimscale ( / desc )

    (princ
        (strcat "Dimscale is "
            (if
                (setq desc
                    (cadr
                        (assoc (getvar "dimscale")
                           '(
                                (  1 "12\" = 1'")
                                (  2 "6\" = 1'")
                                (  3 "4\" = 1'")
                                (  4 "3\" = 1'")
                                (  6 "2\" = 1'")
                                (  8 "1-1/2\" = 1'")
                                ( 12 "1\" = 1'")
                                ( 16 "3/4\" = 1'")
                                ( 24 "1/2\" = 1'")
                                ( 32 "3/8\" = 1'")
                                ( 48 "1/4\" = 1'")
                                ( 64 "3/16\" = 1'")
                                ( 96 "1/8\" = 1'")
                                (128 "3/32\" = 1'")
                                (192 "1/16\" = 1'")
                                (384 "1/32\" = 1'")
                            )
                        )
                    )
                )
                desc
                "NOT STANDARD"
            )
            "\n"
        )
    )
   
    (princ)       

)

I see CAB posted near verbatim code; sweet.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

dustinthiesse

  • Guest
Re: Dimscale display
« Reply #23 on: January 30, 2009, 10:52:32 AM »
Nice CAB!!!

I've always used "assoc" when dealing with DFX lists, but never really thought about what it actually did haha.

This turns on so many lights!  :roll:

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Dimscale display
« Reply #24 on: January 30, 2009, 11:03:30 AM »
Wow MP, that's spooky.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Dimscale display
« Reply #25 on: January 30, 2009, 11:16:53 AM »
One upon a time it may have been spooky. After all these years being co-contributers (if I may be so immodest) to the swamp? Not so much.  :-)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Spike Wilbury

  • Guest
Re: Dimscale display
« Reply #26 on: January 30, 2009, 11:31:05 AM »
One upon a time it may have been spooky. After all these years being co-contributers (if I may be so immodest) to the swamp? Not so much.  :-)

when i was a lisp coder... i did or use many times an approach similar as yours....

Code: [Select]
;;;=========================================================

  (cond ;; no lleva marco, crear la variable "_tframe" = a "none" para compararla
;; dentro de la funcion "qdr-opening" que esta en idoor.lsp
((= idoor_frame "none") (setq _tframe "none"))
((= idoor_frame "2")
(setq _tframe "2")
(setq *rcmdFrameWidth* 2.0))
((= idoor_frame "4")
(setq _tframe "4")
(setq *rcmdFrameWidth* 4.0)))
  ;; tipo de puerta
  (setq block_dwg
(cdr
   (assoc idoor_doorname
  (list (cons "90 degrees swing" "90")
(cons "45 degrees swing" "45")
(cons "30 degrees swing" "30")
(cons "15 degrees swing" "15")
(cons "180 degrees swing" "180")
(cons "Pair 90 degrees swing" "PAIR")
(cons "Pair 90 degrees double egress" "DOUBLEA")
(cons "Sliding" "SLIDING")
(cons "Pocket" "POCKET")
(cons "Folding" "FOLDING")
(cons "Rolling" "ROLLING")))))

  ;; asegurarme que esta lista este vacia
  (setq marcos_lst nil)

  ;; instalar "point-x"
  (if (= idoor_position "point")
    (progn (setq encased idoor_opening)
   (setq ss (qdr-door-installer
      ;; distancia a la esquina
      (distof idoor_corner_ref 4)
      nil
      ;; ancho de la puerta
      (distof idoor_door_width 4)))))
  ;; instalar "centered"
  (if (= idoor_position "center")
    (progn (setq encased idoor_opening)

a code done many moons ago....  :-P

 :-)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Dimscale display
« Reply #27 on: January 30, 2009, 11:44:56 AM »
Code: [Select]
...   (list (cons "90 degrees swing" "90")
(cons "45 degrees swing" "45")
(cons "30 degrees swing" "30")
(cons "15 degrees swing" "15")
(cons "180 degrees swing" "180")
(cons "Pair 90 degrees swing" "PAIR")
(cons "Pair 90 degrees double egress" "DOUBLEA")
(cons "Sliding" "SLIDING")
(cons "Pocket" "POCKET")
(cons "Folding" "FOLDING")
(cons "Rolling" "ROLLING")))))

I'm curious Luis, why not just quote the data since it's all literals?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Spike Wilbury

  • Guest
Re: Dimscale display
« Reply #28 on: January 30, 2009, 11:48:02 AM »
Code: [Select]
...   (list (cons "90 degrees swing" "90")
(cons "45 degrees swing" "45")
(cons "30 degrees swing" "30")
(cons "15 degrees swing" "15")
(cons "180 degrees swing" "180")
(cons "Pair 90 degrees swing" "PAIR")
(cons "Pair 90 degrees double egress" "DOUBLEA")
(cons "Sliding" "SLIDING")
(cons "Pocket" "POCKET")
(cons "Folding" "FOLDING")
(cons "Rolling" "ROLLING")))))

I'm curious Luis, why not just quote the data since it's all literals?

No idea.

That is one of my first lisps... to old - it is abandoned as basically all of my lisp routines....  :-(

:)

Luke

  • Guest
Re: Dimscale display
« Reply #29 on: January 30, 2009, 11:48:43 AM »
Thanks all.  I appreciate it.  Little by little I'm getting a better understanding.