Jump to content
mhupp

Drawer blocks

Recommended Posts

mhupp

So I have the following code to make drawer blocks quickly

 

;;----------------------------------------------------------------------;;
; Quick Drawer block
; Creates a Drawer_# block from selected objects
(defun C:QD (/ selectionset insertionpoint number Blockname)
  (setvar 'clayer "0")
  (if (and (setq selectionset (ssget "_:L"))
           (setq insertionpoint (getpoint "\n Specify insertion point :"))
      )
    (progn
      (setq number    1
            Blockname (strcat "Drawer_" (itoa number))
      )
      (while (tblsearch "BLOCK" Blockname)
        (setq Blockname
               (strcat "Drawer_" (itoa (setq number (1+ number))))
        )
      )
      (command "_.-Block" Blockname insertionpoint selectionset "")
      (command "_.-insert" Blockname insertionpoint "" "" "")
      (command "_.pan" "0,0" "0,27.5")
      (print(strcat Blockname " is Made"))
    )
    (princ)
  )
  (princ)
)

What i would like to do is make the pan command dynamic between drawings. The first time running Quick Drawer command it will ask for user input for the pan distance by selecting two points. When the command is repeated the distance is already set and wont ask for it again.

Share this post


Link to post
Share on other sites
BIGAL

A couple of ways write to the registery, setenv and retrieve, write to a file handy for server situation.

Share this post


Link to post
Share on other sites
mhupp

Just want it stored when a drawing is active. so i guessing I need an if statement after i change the layer to 0 right?

Share this post


Link to post
Share on other sites
BIGAL

Maybe 

 


(if (= pt1 nil)(setq pt1 (list 0 0)))

(if (= pt2 nil)(setq pt2 (list 0 27.5)))

………..

(command "_.pan" pt1 pt2)

Share this post


Link to post
Share on other sites
ronjonp
13 hours ago, BIGAL said:

Maybe 

 

 


(if (= pt1 nil)(setq pt1 (list 0 0)))

(if (= pt2 nil)(setq pt2 (list 0 27.5)))

………..

(command "_.pan" pt1 pt2)

 

@BIGAL

FWIW

;; This is the same logic
(or pt1 (setq pt1 '(0 0)))
(or pt2 (setq pt2 '(0 27.5)))
;; Or this :)
(command "_.pan" (cond (pt1) ('(0 0))) (cond (pt2) ('(0 27.5))))

 

Share this post


Link to post
Share on other sites
mhupp
Posted (edited)

I couldn't get either of those too work just kept offsetting 27.5

 

the 27.5 is just a hard coded value. kind of a place holder because that's around the average distance to pan down. 

 

when running the command for the first time check the dist variable has been set.

if not run a smaller command that only sets the dist variable.

run rest of code like normal.

use dist variable in pan command to offset that distance.

Want to set the distance in a different macro so i can change if need be with out closing the drawing.

 

;;----------------------------------------------------------------------;;
; Quick Drawer block
; Creates a Drawer_# block from selected objects
(defun C:QD (/ selectionset insertionpoint number Blockname dist)
  (setvar 'clayer "0")
  (if dist (C:QDD) 'if dist isn't set run command QDD
  .
  .
  .
      (command "_.pan" "0,0" "0,dist") 'use dist varable here to offset dont know what to put here to call value back.
      (print(strcat Blockname " is Made"))
    )
    (princ)
  )
  (princ)
)

(defun C:QDD ()
  (prompt "\nSelect Distance to offset")
  (setq dist (distance p1 p2))
)
 

 

Edited by mhupp

Share this post


Link to post
Share on other sites
BIGAL

Lisp incorrect

 


(if dist (c:QDD)

(if (= dist nil)(C:qdd))

 

(setq dist (distance pt1 pt2))

(setq dist (distance (getpoint "pick point1")(getpoint "\npick point2")))

8 hours ago, mhupp said:

(if dist (C:QDD)

 

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...