Help a newbie solve a simple problem

Help a newbie solve a simple problem

Jose_Gaudencio
Contributor Contributor
316 Views
3 Replies
Message 1 of 4

Help a newbie solve a simple problem

Jose_Gaudencio
Contributor
Contributor

As the title says I'm newbie in programming. I'm a topographer engineer looking to optimize his work with lisps.

I leave the LISP file attached with the lines of code that I wrote with the help of posts in this forum and videos on YouTube.

The code is very simple and has a comment explaining the process.

I hope some kind user helps me, and most importantly, explain what I did wrong so I can learn 😄

 

EDIT: this is my first LIPS, don't be hard on me

0 Likes
Accepted solutions (1)
317 Views
3 Replies
Replies (3)
Message 2 of 4

komondormrex
Mentor
Mentor
Accepted solution

is that what you want?

 

(defun c:rebatimento()
  (setq obj (entsel "\nSelect object to be copied: "))
  (setq obj1 (car obj))
  (setq obj2 (cadr obj))
  (command "_.COPYclip" obj1 "")	;	changed	
  (setq coord (getpoint "\nEnter the coordinates to paste the object: "))

; Get elevation of reference surface and point
  (setq zref (getreal "\nEnter value of reference surface: "))
  (setq zpont (getreal "\nEnter the value of the point: "))

; Substitute the y coordinate
  (setq finalcoord (list (nth 0 coord) (* (- zpont zref) 5) 0.0))

; Repeat the paste process until the user cancels
  (while t	;	changed
      (command "_.pasteclip" finalcoord)
      (setq coord (getpoint "\nEnter the coordinates to paste the next object (or press Enter to cancel): "))
      (setq zpont (getreal "\nEnter the value of the point: "))
      (setq finalcoord (list (nth 0 coord) (* (- zpont zref) 5) 0))
    );while
  
);defun

 

0 Likes
Message 3 of 4

Jose_Gaudencio
Contributor
Contributor

That solve the problem. Thank you.

But i continued to work on the code and got close to the final program but now i'm facing a small situation xD

 

(defun c:rebatimento()
  (setq obj (ssget))
  (command "._COPYclip" obj (getpoint "\nEnter base point: ") "")
  (setq coord (getpoint "\nEnter the coordinates to paste the object: "))

; Get elevation of reference surface and point
  (setq zref (getreal "\nEnter value of reference surface: "))
  (setq zpont (getreal "\nEnter the value of the point: "))

; Substitute the y coordinate
  (setq finalcoord (list (nth 0 coord) (* (- zpont zref) 5) 0.0))
  
; Repeat the paste process until the user cancels
  (while
    (progn
      (command "._pasteclip" finalcoord "")
      (setq coord (getpoint "\nEnter the coordinates to paste the next object (or press Enter to cancel): "))
      (setq zpont (getreal "\nEnter the value of the point: "))
      (setq finalcoord (list (nth 0 coord) (* (- zpont zref) 5) 0))
    );progn
   );while
  
);defun

The program doesn't take the base point i choose and pastes the objects with an offset. Can you tell me what im doing wrong, please?

Top point are inserted by the LISP programTop point are inserted by the LISP program

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

Are you perhaps not in PLAN view?

Kent Cooper, AIA
0 Likes