OMG - Thank you very much ronjonp! :smitten:Glad to help :)
My day can not be ruined
Christina
RonJon,Post a picture of what you're trying to explain.
Don't know if I can ask another question, but that's the last one! :oops:
After pick the rectangle, Lisp asks how many divisions I want on the longest side.
If I type 3 the code divides the rectangle into 3 parts and draws diagonal lines in the 3 parts...
Thanks again for your previous code(very happy)!
Christina
; segment rectangs with verts and X.
; By AlanH April 2021
(defun c:zigzag ( / oldsnap pt pt1 pt2 pt3 pt4 ang1 ang2 dist1 dist2 lst lst2 x y )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq pt (getpoint "\nPick point inside rectang "))
(command "bpoly" pt "")
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(command "erase" (entlast) "")
(setq pt1 (nth 0 co-ord)
pt2 (nth 1 co-ord)
pt3 (nth 2 co-ord)
pt4 (nth 3 co-ord)
ang1 (angle pt1 pt2)
ang2 (angle pt4 pt3)
dist1 (distance pt1 pt2)
dist2 (distance pt4 pt3)
)
(setq num (getreal "\Enter number of segments "))
(setq lst '())
(setq lst2 '())
(setq x 1.0)
(repeat (- (fix num) 1)
(setq lst (cons (polar pt1 ang1 (* dist1 (/ x num))) lst))
(setq lst2 (cons (polar pt4 ang2 (* dist2 (/ x num))) lst2))
(setq x (+ x 1))
)
(setq lst (reverse lst ))
(setq lst2 (reverse lst2))
; verts
(setq y 0)
(repeat (length lst)
(command "line" (nth y lst)(nth y lst2) "")
(setq y (+ y 1))
)
; do ends
(setq y 0)
(command "line" pt1 (nth y lst2) "")
(command "line" pt4 (nth y lst) "")
(setq y (- (length lst) 1))
(command "line" pt2 (nth y lst2) "")
(command "line" pt3 (nth y lst) "")
; do mids
(setq y 0)
(repeat (- (length lst) 1)
(command "line" (nth y lst2) (nth (+ y 1) lst) "")
(command "line" (nth y lst) (nth (+ y 1) lst2) "")
(setq y (+ y 1))
)
(setvar 'osmode oldsnap)
(princ)
)
(c:zigzag)
(http://)And the photoJust curious, in what profession do you use these 'x' boxes?
Here is my attempt for your second request and hopefully Ron won't mind.Not at all :)
...
Just curious, in what profession do you use these 'x' boxes?
Hello Tharwat,You're welcome.
Much appreciate your effort!
I have been testing a lot and only a few times it went wrong. But I am very satisfied!
Here is a photo just to be sure because you may know why it can go wrong?
It only happens with a standing rectangle, straight with 4 angles of 90 °.
Cannot reproduce the error it happened spontaneously... with the same error over and over; the zigzag goes to the right as shown in the picture.
Can you please share that part of the drawing where the program fails to produce the correct shape ?
Its not a matter of guessing. :no:QuoteCan you please share that part of the drawing where the program fails to produce the correct shape ?
Maybe you need only to set OSMODE=0
Its not a matter of guessing.
Why to guess since the codes in front of you that you can read to know if your expectation was right ?QuoteIts not a matter of guessing.
to understand, sometimes you need to make assumptions. . .
Why to guess since the codes in front of you that you can read to know if your expectation was right ?
Can you please share that part of the drawing where the program fails to produce the correct shape ?
; segment rectangs with verts and X.
; By AlanH April 2021
(defun c:zigzag ( / oldsnap pt pt1 pt2 pt3 pt4 ang1 ang2 dist1 dist2 lst lst2 x y )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq pt (getpoint "\nPick point inside rectang "))
(command "bpoly" pt "")
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(command "erase" (entlast) "")
(setq pt1 (nth 0 co-ord)
pt2 (nth 1 co-ord)
pt3 (nth 2 co-ord)
pt4 (nth 3 co-ord)
ang1 (angle pt1 pt2)
ang2 (angle pt4 pt3)
dist1 (distance pt1 pt2)
dist2 (distance pt4 pt3)
)
(if (> dist1 dist2)
(setq co-ord (list (nth 1 co-ord)(nth 2 co-ord)(nth 3 co-ord)(nth 0 co-ord)))
)
(setq num (getreal "\Enter number of segments "))
(setq lst '())
(setq lst2 '())
(setq x 1.0)
(repeat (- (fix num) 1)
(setq lst (cons (polar pt1 ang1 (* dist1 (/ x num))) lst))
(setq lst2 (cons (polar pt4 ang2 (* dist2 (/ x num))) lst2))
(setq x (+ x 1))
)
(setq lst (reverse lst ))
(setq lst2 (reverse lst2))
; verts
(setq y 0)
(repeat (length lst)
(command "line" (nth y lst)(nth y lst2) "")
(setq y (+ y 1))
)
; do ends
(setq y 0)
(command "line" pt1 (nth y lst2) "")
(command "line" pt4 (nth y lst) "")
(setq y (- (length lst) 1))
(command "line" pt2 (nth y lst2) "")
(command "line" pt3 (nth y lst) "")
; do mids
(setq y 0)
(repeat (- (length lst) 1)
(command "line" (nth y lst2) (nth (+ y 1) lst) "")
(command "line" (nth y lst) (nth (+ y 1) lst2) "")
(setq y (+ y 1))
)
(setvar 'osmode oldsnap)
(princ)
)
(c:zigzag)
It would be a great idea to consider a few fees
Would appreciate if you could try it
just 1 question does it check the rise/run rules for stairs ?First there is a difference between DCL and OpenDCL...
This is plain Autocad developed 1990's still available very cheap PM me.
My second version of the program provided works for me in all circumstances and I already recorded a quick demo showing that the program also works on the drawing you attached where the program failed for you.
Solving a problem that pops up now and then and works for some people and not are a deadly challenge...Just wondering whom these people are?
So, my logic tells me that the fault lies with me and need to reinstall my Windows and AutoCad because the problem will also continue with fees.I believe the problem has nothing to do with Windows nor AutoCAD.
my mom will borrow me little money and will contact you.Please do not, I don't like to feel guilty against anyone, so I will never accept that.
Just wondering whom these people are?
I believe the problem has nothing to do with Windows nor AutoCAD.I believe you, but I work in steps and will be sure that Win + Acad are no longer my problem.
(defun c:zigzag ( / oldsnap pt pt1 pt2 pt3 pt4 ang1 ang2 dist1 dist2 lst lst2 x y )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq pt (getpoint "\nPick point inside rectang "))
(command "bpoly" pt "")
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(command "erase" (entlast) "")
(setq pt1 (nth 0 co-ord)
pt2 (nth 1 co-ord)
pt3 (nth 2 co-ord)
pt4 (nth 3 co-ord)
ang1 (angle pt1 pt2)
ang2 (angle pt4 pt3)
dist1 (distance pt1 pt2)
dist2 (distance pt4 pt3)
)
(if (> dist1 dist2)
(setq co-ord (list (nth 1 co-ord)(nth 2 co-ord)(nth 3 co-ord)(nth 0 co-ord)))
)
(setq num (getreal "\Enter number of segments "))
(if (> num 1)
(progn
(setq lst '())
(setq lst2 '())
(setq x 1.0)
(repeat (- (fix num) 1)
(setq lst (cons (polar pt1 ang1 (* dist1 (/ x num))) lst))
(setq lst2 (cons (polar pt4 ang2 (* dist2 (/ x num))) lst2))
(setq x (+ x 1))
)
(setq lst (reverse lst ))
(setq lst2 (reverse lst2))
; do ends
(setq y 0)
(command "line" pt1 (nth y lst2) "")
(command "line" pt4 (nth y lst) "")
(setq y (- (length lst) 1))
(command "line" pt2 (nth y lst2) "")
(command "line" pt3 (nth y lst) "")
; verts
(setq y 0)
(repeat (length lst)
(command "line" (nth y lst)(nth y lst2) "")
(setq y (+ y 1))
)
; do mids
(setq y 0)
(repeat (- (length lst) 1)
(command "line" (nth y lst2) (nth (+ y 1) lst) "")
(command "line" (nth y lst) (nth (+ y 1) lst2) "")
(setq y (+ y 1))
)
)
(progn
(Command "line" (nth 0 co-ord)(nth 2 co-ord) "")
(Command "line" (nth 1 co-ord)(nth 3 co-ord) "")
)
)
(setvar 'osmode oldsnap)
(princ)
)
(c:zigzag)
Studied all the code I received and mixed it together to form the bulletproof cocktail for my computer.
The code is not 100% correct and is not elegant but does what it should do.
Honesty is required all the time even if we are hidden behind our screens.
You never reply me about the results in TEST63.dwg and TEST45.dwg... take the test and you will also know if your code works.
(defun c:zigzag ( / oldsnap pt pt1 pt2 pt3 pt4 ang1 ang2 dist1 dist2 lst lst2 x y )
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)
(setq pt (getpoint "\nPick point inside rectang "))
(command "bpoly" pt "")
(setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (entlast)))))
(command "erase" (entlast) "")
(setq pt1 (nth 0 co-ord)
pt2 (nth 1 co-ord)
pt3 (nth 2 co-ord)
pt4 (nth 3 co-ord)
ang1 (angle pt1 pt2)
ang2 (angle pt4 pt3)
dist1 (distance pt1 pt2)
dist2 (distance pt4 pt3)
)
(if (> dist1 dist2)
(setq co-ord (list (nth 1 co-ord)(nth 2 co-ord)(nth 3 co-ord)(nth 0 co-ord)))
)
(setq num (getreal "\Enter number of segments "))
(if (> num 1)
(progn
(setq lst '())
(setq lst2 '())
(setq x 1.0)
(repeat (- (fix num) 1)
(setq lst (cons (polar pt1 ang1 (* dist1 (/ x num))) lst))
(setq lst2 (cons (polar pt4 ang2 (* dist2 (/ x num))) lst2))
(setq x (+ x 1))
)
(setq lst (reverse lst ))
(setq lst2 (reverse lst2))
; do ends
(setq y 0)
(command "line" pt1 (nth y lst2) "")
(command "line" pt4 (nth y lst) "")
(setq y (- (length lst) 1))
(command "line" pt2 (nth y lst2) "")
(command "line" pt3 (nth y lst) "")
; verts
(setq y 0)
(repeat (length lst)
(command "line" (nth y lst)(nth y lst2) "")
(setq y (+ y 1))
)
; do mids
(setq y 0)
(repeat (- (length lst) 1)
(command "line" (nth y lst2) (nth (+ y 1) lst) "")
(command "line" (nth y lst) (nth (+ y 1) lst2) "")
(setq y (+ y 1))
)
)
(progn
(Command "line" (nth 0 co-ord)(nth 2 co-ord) "")
(Command "line" (nth 1 co-ord)(nth 3 co-ord) "")
)
)
(setvar 'osmode oldsnap)
(princ)
)
(c:zigzag)
Why did you create the layer "KASTEN" with pink colour [ 6 ] and assigned the line's colour to gray [ 9 ] as well as the LineType also ?The consequences of cutting and pasting and too late in my bed...
Thank you very much, tested extensively almost all day between breaks and have to say that it works perfectly in all situations.Great to hear that.
The consequences of cutting and pasting and too late in my bed...If you write codes from scratch that would be much better for your learning even you are repeating the same codes in multiple routines, so I believe copy and paste codes will keep you in the back seat no matter how long have you been coding. :sleezy: