a lisp need help to complete

a lisp need help to complete

DOODLEANU
Enthusiast Enthusiast
823 Views
8 Replies
Message 1 of 9

a lisp need help to complete

DOODLEANU
Enthusiast
Enthusiast

need the mirror function to be working properly , also before a preview of the block the mirror orientation to confirm, but don't know how to do !! An imaginary working illustrated below as gif.

DOODLEANU_0-1723971690653.gif

 

 

 

(defun c:INCAP ()
  (setq blkname "CAP")
  (setq inspt (getpoint "\nclick insertion point for block: "))
  (setq inspt (list (car inspt) (cadr inspt) 0.0))
  (setq dirpt (getpoint inspt "\nclick direction: "))
  (setq rotangle (angle inspt dirpt))
  (setq rotangle (* rotangle (/ 180.0 pi)))
  (command "_.insert" blkname inspt 1.0 1.0 rotangle)
  (command "_.mirror" blkname inspt dirpt "N")
  (princ "\nBlock insertion complete with direction-based rotation.")
)

 

 

 

 

 

 

 

0 Likes
Accepted solutions (1)
824 Views
8 Replies
Replies (8)
Message 2 of 9

-didier-
Advisor
Advisor

Bonjour @DOODLEANU 

 

Why do you want to use LSP ?

Is it mandatory?

It’s possible but a little “advanced”.

With an inversion parameter, it will work like that : is it OK ?

 

Amicalement

 

2024-08-18_11-36-07.gif

 

Éternel débutant.. my site for learning : Programmer dans AutoCAD

DA

EESignature

0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

@DOODLEANU wrote:

need the mirror function to be working properly , .


Explain in more detail, please.  The routine does not involve any Mirror function, so it's hard to picture in what way that could be not "working properly."

Kent Cooper, AIA
Message 4 of 9

DOODLEANU
Enthusiast
Enthusiast

Yah, doing with lisp it can be more faster, and easier on my particular scenario. 

0 Likes
Message 5 of 9

DOODLEANU
Enthusiast
Enthusiast

Step 1: Click to set the insertion point of the block.

Step 2: Choose the rotation angle by clicking a direction point.

from step 3 onwards i m not capable to write in lisp

Step 3: Turn on ortho mode. activate the mirror command, find the mirror line is same as between the insertion point and the 90DGR angular up or down direction point.
Move the cursor to the opposite side of the mirror line; AutoCAD will show a preview of the mirrored object as per illustration gif at message 1.

Step 4:

If you click on the mirrored side, delete the original object and keep the mirrored one.

If you click on the non-mirrored side, skip the mirror action.

 

An another way of thinking.

After step 2, insert block regarding directional line, save name that block (REALBLOCK) 

Instantly mirror it back to back , save name that block (MIRBLOCK) 

While mouse move the direction, one of the block need to deleted so only one block remain either REALBLOCK or MIRBLOCK, that consider as preview 

by clicking the mouse point its confirm and result end with only one block either MIRBLOCK or REALBLOCK

 

Thank you 

0 Likes
Message 6 of 9

paullimapa
Mentor
Mentor

This will partially get you there if you replace this line 

(command "_.mirror" blkname inspt dirpt "N")

with this line to at least finish the mirror command

(command "_.mirror" (entlast) "" inspt dirpt "_N")

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

komondormrex
Mentor
Mentor
Accepted solution

check the following

(defun c:INCAP ()
  	(setq blkname "CAP")
  	(setq inspt (getpoint "\nclick insertion point for block: "))
  	(setq inspt (list (car inspt) (cadr inspt) 0.0))
  	(setq dirpt (getpoint inspt "\nclick direction: "))
  	(setq rotangle (angle inspt dirpt))
  	(setq rotangle_d (* rotangle (/ 180.0 pi)))
  	(command "_.insert" blkname inspt 1.0 1.0 rotangle_d)
	(while (= 5 (car (setq dir_point (grread t 5 0))))
			(if (equal rotangle
					   (angle inspt (inters (cadr dir_point) 
					   						(polar (cadr dir_point) (+ (* 0.5 pi) rotangle) 1)
											inspt 
											(polar inspt rotangle 1)
											nil
									)
					   )     
					   1e-6
				)
				(setpropertyvalue (entlast) "ScaleFactors/X" 1)
				(setpropertyvalue (entlast) "ScaleFactors/X" -1)
			)
	)
  	(princ "\nBlock insertion complete with direction-based rotation.")
	(princ)
)
Message 8 of 9

DOODLEANU
Enthusiast
Enthusiast

Instead of mirroring, it made  exact 2 copies of the block 😞

0 Likes
Message 9 of 9

DOODLEANU
Enthusiast
Enthusiast

Yes , yes.

This is what I mean. 

wow thank you @komondormrex 

0 Likes