Jump to content

Scale XYZ Value


whosa

Recommended Posts

Hi,

 

I would like to add to this lisp a "variable" scale value.

 

Now is 1.00 but sometime I need to scale it down.

 

It could work like this:

 

  1. 1.00 by default
  2. Ask me if I want to change the scale value
  3. Keep the new value until I close the DWG. 

 

Can someone help me on this?

 

Thanks,

 

Santo

 

(defun c:CRD (/ sp p)
(command "UCS" "world")
  (setq sp
         (vlax-get (vla-get-activelayout
                     (vla-get-ActiveDocument (vlax-get-acad-object)))
                   'Block)
        )
  (if (tblsearch "BLOCK" "STREET2" )
    (while (setq p (getpoint "\nSpecify point :"))
      (vla-put-textstring
        (car (vlax-invoke
               (vla-insertblock
                 sp
                 (vlax-3d-point p)
                 "STREET2"
                 1.0
                 1.0
                 1.0
                 0.0)
               'getattributes))
        
	(rtos (/ (caddr p) 1000.) 2 2)
        )

      )
    )
  (princ)
(command "UCS" "_p")
  )(vl-load-com)

 

Edited by whosa
Link to comment
Share on other sites

You could try something like this -

(defun c:crd ( / ang att blk ins obj scl spc )
    
    (setq blk "street2")
    
    (if (tblsearch "block" blk)
        (progn
            (if (null crd:scl)
                (setq crd:scl 1.0)
            )
            (initget 6)
            (if (setq scl (getreal (strcat "\nSpecify scale <" (rtos crd:scl 2) ">: ")))
                (setq crd:scl scl)
                (setq scl crd:scl)
            )
            (setq ang (angle '(0 0) (trans (getvar 'ucsxdir) 0 (trans '(0 0 1) 1 0 t) t))
                  spc (vlax-get-property (vla-get-activedocument (vlax-get-acad-object))
                          (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)
                      )
            )
            (while (setq ins (getpoint "\nSpecify insertion point <exit>: "))
                (if (setq obj (vla-insertblock spc (vlax-3D-point (trans ins 1 0)) blk scl scl scl ang)
                          att (car (vlax-invoke obj 'getattributes))
                    )
                    (vla-put-textstring att (rtos (/ (caddr (trans ins 1 0)) 1000.0) 2 2))
                )
            )
        )
        (princ (strcat "\nBlock " blk " is not defined in the active drawing."))
    )
    (princ)
)
(vl-load-com) (princ)

 

Edited by Lee Mac
  • Like 1
Link to comment
Share on other sites

(if (and (or (tblsearch "BLOCK" "STREET2")
             (alert "Block < STREET2 > was not found <!>")
         )
         (or *sclval* (setq *sclval* 1.0))
         (setq
           *sclval* (cond ((getdist (strcat "\nSpecify the scale value < "
                                            (vl-princ-to-string *sclval*)
                                            " > : "
                                    )
                           )
                          )
                          (*sclval*)
                    )
         )
    )
  (while (setq p (getpoint "\nSpecify point :"))
    (vla-put-textstring
      (car (vlax-invoke
             (vla-insertblock
               sp
               (vlax-3d-point p)
               "STREET2"
               *sclval*
               *sclval*
               *sclval*
               0.0
             )
             'getattributes
           )
      )
      (rtos (/ (caddr p) 1000.) 2 2)
    )
  )
)

 

  • Like 1
Link to comment
Share on other sites

A couple of choices rather than initget 

 

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq ans (atof (nth 0 (ah:butts but "v"  '("Choose 1:  " "1" "0.75" "0.5" "0.25" "0.1" )))))

 

remembers last picked.

 

image.png.712e27fb63899c8c4acfa52378c85197.png

 

Another by lee-mac

(if (not LM:LISTBOX)(LOAD "ListBoxV1-2.lsp")

(setq lst (list "1" "0.75" "0.5" "0.25" "0.1" ))

(LM:LISTBOX "choose" lst 2)

 

image.png.b1d14db42cfe28d4ac2cdca411a56e89.png

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...