Will this autolisp script work on AutoCAD LT 2024

Will this autolisp script work on AutoCAD LT 2024

riggz_wheelz
Explorer Explorer
645 Views
5 Replies
Message 1 of 6

Will this autolisp script work on AutoCAD LT 2024

riggz_wheelz
Explorer
Explorer

I need to know if it will work on AutoCAD LT for my project. I have the full version but it needs to work on AutoCAD LT 2024 as well and I don't have a way to test it.

 

(defun c:PlacePiers (/ pt1 pt2 numBlocks blkName dist angle spacing pt offset i dx dy threshold overlap)
  (setq blkName "PIER") ; Default block name

  ; Prompt user to select two points
  (setq pt1 (getpoint "\nSelect the first point: "))
  (setq pt2 (getpoint "\nSelect the second point: "))

  ; Calculate the distance between the two points
  (setq dist (distance pt1 pt2))

  ; Calculate the change in x and y
  (setq dx (- (car pt2) (car pt1)))
  (setq dy (- (cadr pt2) (cadr pt1)))

  ; Calculate the angle using atan
  (setq angle (atan dy dx))

  ; Prompt user for the number of blocks
  (setq numBlocks (getint "\nEnter the number of blocks to place: "))
  (if (not numBlocks) (setq numBlocks 1)) ; Default to 1 if no input

  ; Calculate the spacing between blocks
  (setq spacing (/ dist (1- numBlocks)))

  ; Set a threshold for overlap checking
  (setq threshold 0.01) ; Adjust this value as needed

  ; Loop to place blocks along the line
  (setq i 0)
  (repeat numBlocks
    (setq offset (* spacing i))
    (setq pt (polar pt1 angle offset))

    ; Check if the point is too close to existing "PIER" blocks
    (setq overlap nil)
    (setq ent (entnext)) ; Start with the first entity in the drawing
    (while ent
      (setq entData (entget ent))
      ; Check if the entity is a "PIER" block
      (if (and (= (cdr (assoc 0 entData)) "INSERT")
               (equal (cdr (assoc 2 entData)) blkName)) ; Check if the block name is "PIER"
        (if (< (distance pt (cdr (assoc 10 entData))) threshold)
          (setq overlap t)
        )
      )
      (setq ent (entnext ent)) ; Move to the next entity
    )

    ; Only place block if no overlap
    (if (not overlap)
      (progn
        ; Create block reference at specified point
        (entmake (list (cons 0 "INSERT")
                       (cons 2 blkName)
                       (cons 10 pt)
                       (cons 41 1) ; X scale
                       (cons 42 1) ; Y scale
                       (cons 50 0) ; Rotation angle
                       ))
      )
    )
    
    (setq i (1+ i))
  )

  (princ "\nBlocks placed successfully.")
  (princ)
)

 

0 Likes
Accepted solutions (2)
646 Views
5 Replies
Replies (5)
Message 2 of 6

paullimapa
Mentor
Mentor
Accepted solution

I don’t see any functions in your code that’s not supported in LT


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 6

diagodose2009
Collaborator
Collaborator
Maybe not work entmake.
In same autocad version/s, entmake can failed.
If are interesed , about more tests, please you replay to me here.
0 Likes
Message 4 of 6

diagodose2009
Collaborator
Collaborator

Exists  anywhere  internet; AutoCadLt read-only Dwg , where  I can Test(s).

compatibility with many program Lisp.

 

I do not, have AutoCad Lt 2020, AutoCad Lt2021, autoCad 2018 Lt , AutoCad2015Lt , AutoLt2011

So many AutoCad/s Lt , I can have, so, i cannot make test/s myself with all these AutoCad*Lt.

Where I can run once AutoLt2015 for tests my program Lisp?

0 Likes
Message 5 of 6

paullimapa
Mentor
Mentor
Accepted solution

AutoCAD LT 2024 is first version to support lisp so all older versions do not


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 6 of 6

Sea-Haven
Mentor
Mentor

I don't see why your asking at all, send to the LT user and ask did it work ? 

0 Likes