Author Topic: Stumpt here  (Read 2590 times)

0 Members and 2 Guests are viewing this topic.

Biscuits

  • Swamp Rat
  • Posts: 502
Stumpt here
« on: October 05, 2019, 02:56:20 PM »
Cobbled this code together to insert a block and change the XScale by entering the new value.
Is there a way to just pick a point (or drag) on the screen instead of typing?
I would love to use dynamic blocks but unable to at work. Thanks


Code: [Select]
;MyCul
(defun C:MC ( / blk newscl i s)
 (setq   CLAY (getvar "CLAYER"))
  (setvar "cmdecho" 1)

(command "-layer" "set" "LAND" "")
(command "-insert" "Cul" pause "1" "" pause "")
(command "._LAYER" "_SET" CLAY "")

  (setvar "cmdecho" 0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 (if (and (not (initget 2))
   (setq i (getreal "\nEnter New Xscale Factor: "))

   (setq s (ssget "L" '((0 . "insert"))))
     )
   (foreach b (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (entmod (mapcar '(lambda (x)
(if (member (car x) '(41))
   (cons (car x) i)
   x
)
       )
      (entget b)
      )
     )
   )
 )
 (princ)
)

Dlanor

  • Bull Frog
  • Posts: 263
Re: Stumpt here
« Reply #1 on: October 05, 2019, 03:32:23 PM »
Try this

Code - Auto/Visual Lisp: [Select]
  1. (setq i_pt (getpoint "\nSelect Insertion Point : "))
  2.  
  3. (setq mdist (getdist i_pt "\nSecond pt :"))
  4.  
  5.  

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Stumpt here
« Reply #2 on: October 05, 2019, 08:55:39 PM »
Like another post I answered Grread is the way around this as it will allow a drag mode. Don't ask me how not my area of expertise. This would be better than using getdist as it needs a rescale factor depending on the size of the block.

« Last Edit: October 05, 2019, 09:00:48 PM by BIGAL »
A man who never made a mistake never made anything

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Stumpt here
« Reply #3 on: October 06, 2019, 10:56:58 AM »
Assuming I've understood what you are looking to achieve, you could try something along the lines of the following:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:mc ( / blk def ent enx lay scl val var )
  2.     (setq lay  "LAND"
  3.           blk  "Cul"
  4.           var '(attreq clayer cmdecho)
  5.           val  (mapcar 'getvar var)
  6.     )
  7.     (cond
  8.         (   (not (or (tblsearch "block" blk) (findfile (strcat blk ".dwg"))))
  9.             (princ (strcat "\nBlock \"" blk "\" not found."))
  10.         )
  11.         (   (progn
  12.                 (if (and (setq def (tblsearch "layer" lay)) (= 0 (logand 1 (cdr (assoc 70 def)))))
  13.                     (setvar 'clayer lay)
  14.                 )
  15.                 (setvar 'attreq  0)
  16.                 (setvar 'cmdecho 0)
  17.                 (setq ent (entlast))
  18.                 (command "_.-insert" blk "_S" 1.0 "\\" "\\")
  19.                 (eq ent (setq ent (entlast)))
  20.             )
  21.         )
  22.         (   (progn
  23.                 (initget 6)
  24.                 (not (setq scl (getdist "\nSpecify new X scale factor: ")))
  25.             )
  26.         )
  27.         (   (progn
  28.                 (setq enx (entget ent))
  29.                 (entmod (subst (cons 41 scl) (assoc 41 enx) enx))
  30.             )
  31.             (entupd ent)
  32.         )
  33.     )
  34.     (mapcar 'setvar var val)
  35.     (princ)
  36. )

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Stumpt here
« Reply #4 on: October 09, 2019, 11:21:19 AM »
Thanks for the help guys. I think I can get this working ......if I ever get the time to get back to it.

Lonnie

  • Newt
  • Posts: 169
Re: Stumpt here
« Reply #5 on: October 10, 2019, 05:27:29 PM »
May or may not help. Here is someone on the AutoDesk site doing something close to what your trying.
I know it's not a drag nor in English but you never can tell where an idea may come from.

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stretching-groups-in-autocad-with-autolisp/td-p/9064941



Biscuits

  • Swamp Rat
  • Posts: 502
Re: Stumpt here
« Reply #6 on: October 10, 2019, 06:10:58 PM »
Thanks for the heads up...maybe we can figure something out as a team.

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Stumpt here
« Reply #7 on: October 11, 2019, 10:13:36 AM »
Finally got it to work...nothing fancy. Thanks again for everyone's help.

Code: [Select]
    (defun c:mc ( / clay pnt1 pnt2 disth newd)

 (setq   CLAY (getvar "CLAYER"))
  (setvar "cmdecho" 1)

(command "-layer" "set" "LAND_CULVERT" "")

    (setq pnt1 (getpoint "\nSpecify Insertion Point: ")
          pnt2 (getpoint "\nSelect 2nd point for Angle and Xscale: " pnt1)
    )

    (setq disth (distance pnt1 pnt2))
    (setq newd (/ disth 0.0346))

 (command "_.-insert" "Culvert1" pnt1 newd "600" pnt2)
 (command "._LAYER" "_SET" CLAY "")

  (setvar "cmdecho" 0)
 (princ)

)