Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp Help "point list management"

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
gccdaemon
466 Views, 8 Replies

Lisp Help "point list management"

I've done all sorts of modification to this routine and can't seem to get it to work right. It's supposed to do the following:

 

1- get 2 user points (GP1 & GP2)

2- Create 2 points (PT1 & PT2) based off GP1

3- Create a selection set (SEL) using PT2 and PT1

4- Move objects in SEL from GP1 to GP2

5- Move objects in SEL again .25 units to the right.

 

(defun C:DETAILMOVE (/ PROGRAM GP1 GP2 PT1 PT2)
	(while	(/= nil	(setq	GP1 (getpoint "Move detail from [press ENTER to finish]: ")))
		(princ	GP1)
		(setq	GP2 (getpoint "Move detail to [press ENTER to finish]: "))
		(princ	GP2)
		(setq	PT1 '((0.05- (car GP1)) (0.05- (cadr GP1))))
		(setq	PT2 '((5.1225+ (car GP1)) (7.05+ (cadr GP1))))
		(setq	SEL (ssget (PT2 PT1)))
		(command "._move" "BOX" SEL "" GP1 GP2 "._move" SEL "" "0,0" "@.25<0")
)	)
(princ)

 

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
8 REPLIES 8
Message 2 of 9
hmsilva
in reply to: gccdaemon

(setq PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05)))
(setq PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05)))

Henrique

EESignature

Message 3 of 9
gccdaemon
in reply to: hmsilva

Command: detailmove
Move detail from [press ENTER to finish]: Move detail to [press ENTER to finish]: ; error: bad function: (11.2095 7.05)

Command:

 

 

Even added the "Z" elevation and got the following:

 

Command: detailmove
Move detail from [press ENTER to finish]: Move detail to [press ENTER to finish]: ; error: bad function: (11.2095 7.05 0.0)
Command:

 

Here is the current code:

 

(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL)
	(while	(/= nil	(setq	GP1 (getpoint "Move detail from [press ENTER to finish]: ")))
		(setq	GP2 (getpoint "Move detail to [press ENTER to finish]: ")
			PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05) (caddr GP1))
			PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05) (caddr GP1))
			SEL (ssget (PT2 PT1)))
		(command "._move" "BOX" SEL "" GP1 GP2 "._move" SEL "" "0,0" "@.25<0")
)	)
(princ)

 

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 4 of 9
hmsilva
in reply to: gccdaemon

I did removed the box option, it needs two points...

And the bad function error was the (ssget (PT2 PT1))

 

(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL)
  (while
    (/=	nil
	(setq GP1 (getpoint "Move detail from [press ENTER to finish]: "))
    )
     (setq GP2 (getpoint "Move detail to [press ENTER to finish]: ")
	   PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05) (caddr GP1))
	   PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05) (caddr GP1))
	   SEL (ssget "_C" PT2 PT1)
     )
     (command "._move" SEL "" GP1 GP2 "._move" SEL "" "0,0" "@.25<0")
  )
  (princ)
)

HTH

Henrique

 

 

 

EESignature

Message 5 of 9
Lee_Mac
in reply to: hmsilva

Some minor additions/changes:

 

 

(defun c:detailmove ( / gp1 gp2 sel )
    (while
        (and
            (setq gp1 (getpoint "Move detail from <Done>: "))
            (setq gp2 (getpoint "Move detail to <Done>: " gp1))
        )
        (if (setq sel
                (ssget "_C"
                    (mapcar '- gp1 '(0.0500 0.05 0.0))
                    (mapcar '+ gp2 '(5.1225 7.05 0.0))
                )
            )
            (command
                "_.move" sel "" "_non" gp1 "_non" gp2
                "_.move" sel "" "_non" '(0.0 0.0) "_non" '(0.25 0.0)
            )
            (princ "\nNo objects found.")
        )
    )
    (princ)
)

 

Message 6 of 9
gccdaemon
in reply to: Lee_Mac

Hmsilva: Your routine doesn't move the 0.25 to the right. Tried messing with it and it still wouldn't go almost like the last "move" command didn't work.

 

Lee: I tried yours and it did the move correctly, but the selection area was off. Looks like you had the SSget set to GP1 AND GP2. It just needed GP1.

 

Did some mods and this is what worked.

 

(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL)
	(while	(and	(setq gp1 (getpoint "Move detail from <Done>: "))
			(setq gp2 (getpoint "Move detail to <Done>: " )))
        (if	(setq sel (ssget "_C" (mapcar '- gp1 '(0.0500 0.05 0.0)) (mapcar '+ gp1 '(5.1725 7.1 0.0))))
		(command "_.move" sel "" "_non" gp1 "_non" gp2
			 "_.move" sel "" "_non" '(0.0 0.0) "_non" '(0.25 0.0))
			 (princ "\nNo objects found."))
	)
	(princ)
)

 Thanks again everyone!

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 7 of 9
Lee_Mac
in reply to: gccdaemon


@gccdaemon wrote:

Lee: I tried yours and it did the move correctly, but the selection area was off. Looks like you had the SSget set to GP1 AND GP2. It just needed GP1.


Ah yes! - I overlooked that on your code Smiley Embarassed

Glad you spotted my mistake & got it working!

Message 8 of 9
gccdaemon
in reply to: Lee_Mac

It doesn't happen often, so I'd call myself lucky for finding it! You've found my mistakes in the past so I promise I won't rub it in, but I can't guarantee someone else won't...lol.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 9 of 9
hmsilva
in reply to: gccdaemon


@gccdaemon wrote:

Hmsilva: Your routine doesn't move the 0.25 to the right. Tried messing with it and it still wouldn't go almost like the last "move" command didn't work.

 ...


Maybe some osnap issue?

On this side works...

Try

 

(defun C:DETAILMOVE (/ GP1 GP2 PT1 PT2 SEL)
  (while
    (/=	nil
	(setq GP1 (getpoint "Move detail from [press ENTER to finish]: "))
    )
     (setq GP2 (getpoint "Move detail to [press ENTER to finish]: ")
	   PT1 (list (- (car GP1) 0.05) (- (cadr GP1) 0.05) (caddr GP1))
	   PT2 (list (+ (car GP1) 5.1225) (+ (cadr GP1) 7.05) (caddr GP1))
	   SEL (ssget "_C" PT2 PT1)
     )
     (command "._move" SEL "" "_non" GP1 "_non" GP2 "._move" SEL "" "_non" "0,0" "_non" "@.25<0")
  )
  (princ)
)

Henrique

 

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost