Lisp :X-CrossLine For Door And Area

Lisp :X-CrossLine For Door And Area

Vuxvix
Advocate Advocate
1,343 Views
23 Replies
Message 1 of 24

Lisp :X-CrossLine For Door And Area

Vuxvix
Advocate
Advocate

Hi!

I use the lisp below to create X-CrossLine into space

 

 

(defun c:XC (/ P1 P2 P3 P4)

;set rectangle points
(setq P1 (getpoint "\nPick corner: "))
(setq P3 (getcorner P1 "\nPick opposite corner: "))
(setq P2 (list (car P1) (cadr P3)))
(setq P4 (list (car P3) (cadr P1)))

(command ".PLINE" P1 P3 "" ".PLINE" P2 P4 "")

(princ))

 

 

I also tried editing this lisp for Door. But there is an error when I snap it into the Door (no error when drawing freely in space)

 

 

 

(defun c:XC1 (/ P1 P2 P3 P4 Midpoint)
; set rectangle points
(setq P1 (getpoint "\nPick corner: "))
(setq P3 (getcorner P1 "\nPick opposite corner: "))
(setq P2 (list (car P1) (cadr P3)))
(setq P4 (list (car P3) (cadr P1)))
(setq Midpoint (list (car P3)(/ (+ (cadr P3) (cadr P4)) 2)))
(command ".PLINE" P1 Midpoint P2 "")
(princ))

 

 

 

Cross line.PNG

 My way to create my desired object is to pick 2 points (like how to draw a rectangle)

Thanks for any help editing it.

0 Likes
Accepted solutions (1)
1,344 Views
23 Replies
Replies (23)
Message 2 of 24

paullimapa
Mentor
Mentor

This is what I get when I run your XC1 code (dash lines I put in):

paullimapa_0-1688007970371.png

Is this not what you want?

 


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

Vuxvix
Advocate
Advocate
Hi! that's what I want.
But when the border is the line (don't close the pline). Error will appear
0 Likes
Message 4 of 24

paullimapa
Mentor
Mentor

no problem for me.

what if you first set OSMODE = 0, then run XC1


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 24

Vuxvix
Advocate
Advocate

>>what if you first set OSMODE = 0, then run XC1
Its look like : (no error when drawing freely in space).>I Think not enough exactly for drawing
here some case i tried.

Some case.PNG

0 Likes
Message 6 of 24

paullimapa
Mentor
Mentor

very odd...

Is UCS set to WORLD?

Is PLAN set to WORLD?

Can you post this sample dwg?


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

Vuxvix
Advocate
Advocate

Hope you find something

0 Likes
Message 8 of 24

paullimapa
Mentor
Mentor

worked perfectly for me...see all the RED lines and attached Sample(1).dwg:

paullimapa_0-1688011717172.png

 


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

Vuxvix
Advocate
Advocate

In your example everything seems to work more correctly. However in case 2-3: Midpoint Point is not exactly Middle to PT1-2 (Y axis). I think my lisp not enought good.
So,If there is another better lisp. Looking forward to sharing. Thanks
Ps: In addition, with double doors. I also don't have any lisp to do that yet.

0 Likes
Message 10 of 24

paullimapa
Mentor
Mentor
Accepted solution

both case 2 & 3 is affected because of preset object snaps

so by just including in your code to set osmode to 0 solved the problem:

paullimapa_0-1688014110575.png

(defun c:XC1 (/ P1 P2 P3 P4 Midpoint osmode)
; set rectangle points
(setq P1 (getpoint "\nPick corner: "))
(setq P3 (getcorner P1 "\nPick opposite corner: "))
(setq P2 (list (car P1) (cadr P3)))
(setq P4 (list (car P3) (cadr P1)))
(setq Midpoint (list (car P3)(/ (+ (cadr P3) (cadr P4)) 2)))
(setq osmode(getvar"osmode")) ; store current setting
(setvar"osmode"0) ; turn off osnap
(command ".PLINE" P1 Midpoint P2 "")
(setvar"osmode"osmode) ; restore setting
(princ))

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

Vuxvix
Advocate
Advocate

When I tried the cases I realized the same thing. However, because I just practice writing lisp, it can't be done. Thanks
Also can I use Mid 2 point(_.m2p)  command instead of setq for 1 Midpoint variable. i want to find a simpler way to implement lisp for double door panel .

0 Likes
Message 12 of 24

paullimapa
Mentor
Mentor

sure this variation of the code as you suggested works also:

(command "_.PLINE" P1 "_M2P" P3 P4 P2 "")

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

Vuxvix
Advocate
Advocate

THIS SIMPLE WAY FOR THE SAME RESULTS. THANKS

0 Likes
Message 14 of 24

paullimapa
Mentor
Mentor

you're very welcome...now using this knowledge you should be able to quickly generate a similar code perhaps called XC2 for the double doors.


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

Vuxvix
Advocate
Advocate
That is exactly its name.
Really, while understanding the variables you call in lisp.
but about the order of command execution- I'm still a bit confused.
If points (P1-4) have been set when selecting points in (Osmode :On) mode.
Then Osmode:Off and draw a PLine that can get the exact point of the rectangle...
0 Likes
Message 16 of 24

paullimapa
Mentor
Mentor

yes, that sequence should work and this is how you should be able to get those points in between:

paullimapa_0-1688018633361.png

 


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

Sea-Haven
Mentor
Mentor

Wow lots of posts can be solved using a dynamic block. Can have different visibilty states obvious is for window 4 states up down left right. Also length and height change, X lines are maintained.

 

SeaHaven_1-1688183091922.png

 

 

0 Likes
Message 18 of 24

Vuxvix
Advocate
Advocate

Hi!
100% agree. We have many ways to do this. I also use Dynamic Block a lot myself. Here simply, I'm trying using Lisp.

0 Likes
Message 19 of 24

WeTanks
Mentor
Mentor

@paullimapa 

Why do you need to set osmode to 0?

どうしてスナップを0に設定する必要がありますか。

We.Tanks

EESignature

A couple of Fusion improvement ideas that could your vote/support:
図面一括印刷

0 Likes
Message 20 of 24

paullimapa
Mentor
Mentor

Users may have set running object snaps. When this happens and the code draws the PLINE and then specific a coordinate (x,y) for the start point, it'll then use the object snap setting instead of the actual coordinate location. So it's best to build into the code to account for the possibility by turning the object snap off (OSMODE 0), and then after the PLINE completes put the object snap setting back.


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