Author Topic: ==={Challenge}===Find the ridge lines of sloped roof  (Read 106196 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #270 on: January 14, 2024, 06:49:37 PM »
@pkohut

Thanks for interes into this topic... I think I've slightly improved speed of "roof2d-new-new-new.lsp"... The newest version is called "roof2d-new-new-new-n.lsp" and it's posted in ZIP I uploaded at cadtutor download section... Nothing spectacular - removing testing subs for checking for correct finish, added 2 subs - (offd) with (chkcircinside-dist) and adding shorter chk for correct finish in single line :
(vl-every (function (lambda ( x ) (vl-some (function (lambda ( y ) (equal x y 1e-6))) (unique (mapcar (function cadr) lil))))) pl)

That's all from me for now...
Like BIGAL - every millisecond counts...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #271 on: January 14, 2024, 07:34:08 PM »
@ribarm

Quote
posted in ZIP I uploaded at cadtutor download section

I'm old and cranky, so . .

why do you assume that everyone is a member there, and would travel to pick it up ??

I'm noticing this attitude more and more.

This is a peer to peer forum where responsibility to roles is expected to be honoured, and an example set for newer members.

Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

pkohut

  • Bull Frog
  • Posts: 483
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #272 on: January 14, 2024, 10:17:01 PM »
That's all from me for now...
Like BIGAL - every millisecond counts...
M.R.

Sadly, I think, 12 years chasing those milliseconds has given you tunnel vision against better solutions.
New tread (not retired) - public repo at https://github.com/pkohut

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #273 on: January 15, 2024, 02:27:14 AM »
@ribarm

Quote
posted in ZIP I uploaded at cadtutor download section

I'm old and cranky, so . .

why do you assume that everyone is a member there, and would travel to pick it up ??

I'm noticing this attitude more and more.

This is a peer to peer forum where responsibility to roles is expected to be honoured, and an example set for newer members.

Regards,

I don't understand...
Shell I post *.ZIP here?

OK. You can find it here : https://www.theswamp.org/index.php?topic=41837.msg619616#msg619616 in attachment...
« Last Edit: March 04, 2024, 02:17:34 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #274 on: January 22, 2024, 11:01:01 AM »
I've succedded only few lines more on tst.dwg which is packed in *.ZIP... The problem is (processlil) sub function of "roof-2chk-nnnnnnn.lsp" that has (cond) which is doing things from start until hit first that satisfies condition... But in my case we don't know is firstly one be correct choice or some else that also satisfies condition but not placed above the one it hits firstly... What is also different is that I used now "lstt" variable for storing solutions and "lst" is points of LWPOLYLIINE data with angles and adjacent plane prints... So since I made possible on that specific case to acomplish little better results, I am satisfied... As no one is not interested to improve and fix what's done, I may say that I am finished here...
It was my pleasure to lead conversation on this challenge - we all learned something from it...
Thanks for reading and stay well and happy...
M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #275 on: January 24, 2024, 03:53:40 PM »
I abandoned (cond) in (processlil) sub and made it more concise and acceptable to what I tried to achieve... But something still isn't good - in my tst.dwg it draws only few lines and doesn't complete solution... I am afraid that I can't swim out of mug that is draining me... For now I am abandning coding, but am posting in code tags, so that concise version can be seen and maybe someone can chime in and reply with constructive idea(s)...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:roof-2chk-nnnnnnnnnn-s ( / *error* vl-load rlw unioncollinearplaneprints unique inside-p distp2t _vl-sort numbpos offd chkcircinside-dist chkcircinside collinear-pp searchipss processlil process ti s dm lw lwi pl ppl pli tl utl lst llst lstt ll zz x y ip ips ipss pos ang angp flag d t1 t2 tt1 tt2 tt k n att pll lil lilx lil1 lil2 )
  2.  
  3.   (defun *error* ( m )
  4.     ;(command-s "_.-OVERKILL" "_ALL" "" "_T" "_Y" "")
  5.     (if (and lwi (not (vlax-erased-p lwi)))
  6.       (if (= (type lwi) (quote ename))
  7.         (entdel lwi)
  8.         (vla-delete lwi)
  9.       )
  10.     )
  11.     (while (= 8 (logand 8 (getvar (quote undoctl))))
  12.       (if (not (vl-cmdf "_.UNDO" "_E"))
  13.         (if doc
  14.           (vla-endundomark doc)
  15.         )
  16.       )
  17.     )
  18.     (prompt "\nElapsed time : ") (prompt (rtos (- (car (_vl-times)) ti) 2 20)) (prompt " milliseconds...")
  19.     (prompt "\nFor UNDO - type \"UNDO\" - \"Back\" option...")
  20.     (if m
  21.       (prompt m)
  22.     )
  23.     (princ)
  24.   )
  25.  
  26.   (defun vl-load nil
  27.     (or cad
  28.         (setq cad (vlax-get-acad-object))
  29.         (progn
  30.           (vl-load-com)
  31.           (setq cad (vlax-get-acad-object))
  32.         )
  33.       )
  34.     )
  35.     (or doc (setq doc (vla-get-activedocument cad)))
  36.     (or alo (setq alo (vla-get-activelayout doc)))
  37.     (or spc (setq spc (vla-get-block alo)))
  38.   )
  39.  
  40.   (defun rlw ( lw / e x1 x2 x3 x4 x5 x6 )
  41.     ;; by ElpanovEvgeniy
  42.     (if (= (cdr (assoc 0 (setq e (entget lw)))) "LWPOLYLINE")
  43.       (progn
  44.         (foreach a1 e
  45.           (cond
  46.             ( (= (car a1) 10) (setq x2 (cons a1 x2)) )
  47.             ( (= (car a1) 40) (setq x4 (cons (cons 41 (cdr a1)) x4)) )
  48.             ( (= (car a1) 41) (setq x3 (cons (cons 40 (cdr a1)) x3)) )
  49.             ( (= (car a1) 42) (setq x5 (cons (cons 42 (- (cdr a1))) x5)) )
  50.             ( (= (car a1) 210) (setq x6 (cons a1 x6)) )
  51.             ( t (setq x1 (cons a1 x1)) )
  52.           )
  53.         )
  54.         (entmod
  55.           (append (reverse x1)
  56.             (append
  57.               (apply (function append)
  58.                 (apply (function mapcar)
  59.                   (cons (function list)
  60.                     (list x2
  61.                       (cdr (reverse (cons (car x3) (reverse x3))))
  62.                       (cdr (reverse (cons (car x4) (reverse x4))))
  63.                       (cdr (reverse (cons (car x5) (reverse x5))))
  64.                     )
  65.                   )
  66.                 )
  67.               )
  68.               x6
  69.             )
  70.           )
  71.         )
  72.         (entupd lw)
  73.       )
  74.     )
  75.   )
  76.  
  77.   (defun unioncollinearplaneprints ( tl / a b tll )
  78.     (while (setq a (car tl))
  79.       (setq b (vl-remove-if-not (function (lambda ( x ) (and (collinear-pp (car a) (cadr a) (car x)) (collinear-pp (car a) (cadr a) (cadr x))))) tl))
  80.       (setq tll (cons a tll))
  81.       (if b
  82.         (setq tl (vl-remove-if (function (lambda ( x ) (vl-some (function (lambda ( y ) (equal x y 1e-6))) b))) tl))
  83.         (setq tl (cdr tl))
  84.       )
  85.     )
  86.     tll
  87.   )
  88.  
  89.   (defun unique ( lst / a ll )
  90.     (while (setq a (car lst))
  91.       (if (vl-some (function (lambda ( x ) (equal x a 1e-2))) (cdr lst))
  92.         (setq ll (cons a ll) lst (vl-remove-if (function (lambda ( x ) (equal x a 1e-2))) (cdr lst)))
  93.         (setq ll (cons a ll) lst (cdr lst))
  94.       )
  95.     )
  96.     (reverse ll)
  97.   )
  98.  
  99.   (defun inside-p ( p lw lwi )
  100.   )
  101.  
  102.   (defun distp2t ( p gg / i d )
  103.     (if (setq i (inters p (polar p (+ (angle (car gg) (cadr gg)) (* 0.5 pi)) 1.0) (car gg) (cadr gg) nil))
  104.       (setq d (distance p i))
  105.     )
  106.   )
  107.  
  108.   (defun _vl-sort ( lst func )
  109.     (mapcar
  110.       (function (lambda ( x ) (nth x lst)))
  111.       (vl-sort-i lst func)
  112.     )
  113.   )
  114.  
  115.   (defun numbpos ( n len )
  116.     (cond
  117.       ( (< n len)
  118.         n
  119.       )
  120.       ( (> n len)
  121.         (- n len)
  122.       )
  123.       ( t 0 )
  124.     )
  125.   )
  126.  
  127.   (defun offd ( ip tl / ff d dl )
  128.  
  129.     (defun ff ( ip d )
  130.       (if (not (chkcircinside-dist ip d))
  131.         (progn
  132.           (setq dl (vl-remove-if (function (lambda ( x ) (equal d x 1e-6))) dl))
  133.           (ff ip
  134.             (setq d
  135.               (vl-some
  136.                 (function
  137.                   (lambda ( x )
  138.                     (if
  139.                       (>
  140.                         (-
  141.                           (length dl)
  142.                           (length (vl-remove-if (function (lambda ( y ) (equal x y 1e-5))) dl))
  143.                         ) 2
  144.                       )
  145.                       x
  146.                     )
  147.                   )
  148.                 )
  149.                 (_vl-sort dl (function >))
  150.               )
  151.             )
  152.           )
  153.         )
  154.         d
  155.       )
  156.     )
  157.  
  158.     (setq dl
  159.       (mapcar
  160.         (function
  161.           (lambda ( x )
  162.             (distance ip
  163.               (inters
  164.                 ip
  165.                 (polar ip (+ (* 0.5 pi) (angle (car x) (cadr x))) 1.0)
  166.                 (car x)
  167.                 (polar (car x) (angle (car x) (cadr x)) 1.0)
  168.                 nil
  169.               )
  170.             )
  171.           )
  172.         )
  173.         tl
  174.       )
  175.     )
  176.     (setq d
  177.       (vl-some
  178.         (function
  179.           (lambda ( x )
  180.             (if
  181.               (>
  182.                 (-
  183.                   (length dl)
  184.                   (length (vl-remove-if (function (lambda ( y ) (equal x y 1e-5))) dl))
  185.                 ) 2
  186.               )
  187.               x
  188.             )
  189.           )
  190.         )
  191.         (_vl-sort dl (function >))
  192.       )
  193.     )
  194.     (ff ip d)
  195.   )
  196.  
  197.   (defun chkcircinside-dist ( pp dist / ci ipp ippl params pts tst )
  198.     (if (and pp dist)
  199.       (progn
  200.         (setq ci (entmakex (list (cons 0 "CIRCLE") (cons 10 pp) (cons 40 dist))))
  201.         (setq params (list 0.0 (/ pi 6.0) (/ pi 3.0) (* 0.5 pi) (* 2.0 (/ pi 3.0)) (* 5.0 (/ pi 6.0)) pi (* 7.0 (/ pi 6.0)) (* 4.0 (/ pi 3.0)) (* 1.5 pi) (* 5.0 (/ pi 3.0)) (* 11.0 (/ pi 6.0))))
  202.         (if (setq ipp (vlax-invoke (vlax-ename->vla-object ci) (quote intersectwith) (vlax-ename->vla-object lw) acextendnone))
  203.           (progn
  204.             (while ipp
  205.               (setq ippl (cons (list (car ipp) (cadr ipp)) ippl))
  206.               (setq ipp (cdddr ipp))
  207.             )
  208.             (if ippl
  209.               (setq params (append params (mapcar (function (lambda ( x ) (vlax-curve-getparamatpoint ci x))) ippl)))
  210.             )
  211.             (setq pts (apply (function append) (mapcar (function (lambda ( x ) (list (vlax-curve-getpointatparam ci (- x 0.1)) (vlax-curve-getpointatparam ci (+ x 0.1))))) params)))
  212.             (if (vl-every (function (lambda ( x ) (inside-p x lw lwi))) pts)
  213.               (setq tst (cons t tst))
  214.               (setq tst (cons nil tst))
  215.             )
  216.           )
  217.           (progn
  218.             (setq pts (apply (function append) (mapcar (function (lambda ( x ) (list (vlax-curve-getpointatparam ci (- x 0.1)) (vlax-curve-getpointatparam ci (+ x 0.1))))) params)))
  219.             (if (vl-every (function (lambda ( x ) (inside-p x lw lwi))) pts)
  220.               (setq tst (cons t tst))
  221.               (setq tst (cons nil tst))
  222.             )
  223.           )
  224.         )
  225.         (if (and ci (not (vlax-erased-p ci)))
  226.           (entdel ci)
  227.         )
  228.       )
  229.     )
  230.     (apply (function and) tst)
  231.   )
  232.  
  233.   (defun chkcircinside ( pp tll / dd )
  234.     (if (and pp tll)
  235.       (if (setq dd (offd pp tll))
  236.         (chkcircinside-dist pp dd)
  237.       )
  238.     )
  239.   )
  240.  
  241.   (defun collinear-pp ( p1 p2 p3 )
  242.     ( (lambda ( a b c )
  243.         (or
  244.           (equal (+ a b) c 1e-8)
  245.           (equal (+ b c) a 1e-8)
  246.           (equal (+ c a) b 1e-8)
  247.         )
  248.       )
  249.       (distance p1 p2) (distance p2 p3) (distance p1 p3)
  250.     )
  251.   )
  252.  
  253.   (defun searchipss ( lst / x y ip d dm ipss )
  254.     (setq ll lst dm 1e+308)
  255.     (if (setq x (car lstt))
  256.       (progn
  257.         (setq ll (vl-remove-if (function (lambda ( z ) (vl-some (function (lambda ( a ) (equal (car z) a 1e-6))) (mapcar (function cadr) lil)))) ll))
  258.         (while (setq y (car ll))
  259.           (setq ll (cdr ll))
  260.           (if
  261.             (and x y
  262.               (setq ip (inters (car x) (polar (car x) (cadr x) 1.0) (car y) (polar (car y) (cadr y) 1.0) nil))
  263.               (not (equal ip (car x) 1e-6))
  264.               (not (equal ip (car y) 1e-6))
  265.             )
  266.             (if (not (equal (setq d (distance ip (caar lil))) 0.0 1e-3))
  267.               (if (and d (< d dm) (chkcircinside ip utl))
  268.                 (setq ipss (list ip x y) dm d)
  269.               )
  270.             )
  271.           )
  272.         )
  273.       )
  274.     )
  275.     ipss
  276.   )
  277.  
  278.   (defun processlil ( t1 t2 ipss angp / n ang ips ip lilx )
  279.     (if (and t1 t2 ipss (not (equal t1 t2 1e-6)))
  280.       (progn
  281.         (if (setq ip (inters (car t1) (cadr t1) (car t2) (cadr t2) nil))
  282.           (setq ang (angle (car ipss) ip))
  283.         )
  284.         (if (equal ang angp 1e-6)
  285.           (progn
  286.             (setq n (length tl))
  287.             (foreach tt tl
  288.               (if
  289.                 (and
  290.                   (vl-some (function (lambda ( x ) (equal x (car tt) 1e-6))) (mapcar (function cadr) lil))
  291.                   (vl-some (function (lambda ( x ) (equal x (cadr tt) 1e-6))) (mapcar (function cadr) lil))
  292.                 )
  293.                 (setq tl (vl-remove tt tl))
  294.               )
  295.             )
  296.             (if (= n (length tl))
  297.               (cond
  298.                 ( (and (vl-some (function (lambda ( x ) (or (equal x (caar tl) 1e-6) (equal x (cadar tl) 1e-6)))) (mapcar (function cadr) lil)) (not (vl-some (function (lambda ( x ) (or (equal x (car (last tl)) 1e-6) (equal x (cadr (last tl)) 1e-6)))) (mapcar (function cadr) lil))))
  299.                   (setq tl (cdr tl))
  300.                 )
  301.                 ( (and (vl-some (function (lambda ( x ) (or (equal x (car (last tl)) 1e-6) (equal x (cadr (last tl)) 1e-6)))) (mapcar (function cadr) lil)) (not (vl-some (function (lambda ( x ) (or (equal x (caar tl) 1e-6) (equal x (cadar tl) 1e-6)))) (mapcar (function cadr) lil))))
  302.                   (setq tl (reverse (cdr (reverse tl))))
  303.                 )
  304.               )
  305.             )
  306.             (if (= n (length tl))
  307.               (setq tl (vl-remove (caddar lstt) tl))
  308.             )
  309.             (setq t1 (car tl))
  310.             (setq t2 (last tl))
  311.             (if (setq ip (inters (car t1) (cadr t1) (car t2) (cadr t2) nil))
  312.               (setq ang (angle (car ipss) ip))
  313.             )
  314.           )
  315.         )
  316.         (setq ips (list (car ipss) ang t1 t2))
  317.         (if ips
  318.           (progn
  319.             (setq lstt (cons ips lstt))
  320.             (foreach p pl
  321.               (if (equal (angle p (car ips)) (cadr (assoc p lst)) 1e-6)
  322.                 (if (not (vl-position (list (car ips) p) lil))
  323.                   (setq lilx (cons (list (car ips) p) lilx))
  324.                 )
  325.               )
  326.             )
  327.             (if (not (vl-position (list (car ips) (caar lil)) lil))
  328.               (setq lilx (cons (list (car ips) (caar lil)) lilx))
  329.             )
  330.           )
  331.         )
  332.       )
  333.     )
  334.     (list lilx ang)
  335.   )
  336.  
  337.   (defun process ( lst att / done flag ll ip x y ips ipss d pos zz dm angp lilxa tt tll t1 t2 k )
  338.     (progn
  339.       (while (not done)
  340.         (setq ips nil)
  341.         (if (not flag)
  342.           (progn
  343.             (setq ll lst ips nil dm 1e+308)
  344.             (while (setq x (car ll))
  345.               (setq ll (cdr ll))
  346.               (setq y (car ll))
  347.               (if (and x y (setq ip (inters (car x) (polar (car x) (cadr x) 1.0) (car y) (polar (car y) (cadr y) 1.0) nil)) (inside-p ip lw lwi))
  348.                 (if (< (setq d (min (distp2t ip (caddr x)) (distp2t ip (last y)))) dm)
  349.                   (setq ips (list ip x y) dm d)
  350.                 )
  351.               )
  352.             )
  353.             (setq pos (vl-position (cadr ips) lst))
  354.             (if pos
  355.               (repeat (numbpos pos (length pl))
  356.                 (setq lst (append (cdr lst) (list (car lst))))
  357.                 (setq tl (append (cdr tl) (list (car tl))))
  358.                 (setq pl (append (cdr pl) (list (car pl))))
  359.                 (setq pli (append (cdr pli) (list (car pli))))
  360.               )
  361.             )
  362.             (setq tt (vl-remove-if (function (lambda ( x ) (= (length (vl-remove-if (function (lambda ( y ) (equal x y 1e-6))) (list (caddr (cadr ips)) (cadddr (cadr ips)) (caddr (caddr ips)) (cadddr (caddr ips))))) 2))) (list (caddr (cadr ips)) (cadddr (cadr ips)) (caddr (caddr ips)) (cadddr (caddr ips)))))
  363.             (setq zz (car (vl-remove-if (function (lambda ( x ) (vl-some (function (lambda ( y ) (equal x y 1e-6))) tt))) (list (caddr (cadr ips)) (cadddr (cadr ips)) (caddr (caddr ips)) (cadddr (caddr ips))))))
  364.             (setq tl (vl-remove-if (function (lambda ( x ) (equal x zz 1e-6))) tl))
  365.             (if (and (car ips) (car (cadr ips)) (car (caddr ips)))
  366.               (cond
  367.                 ( (= att 1)
  368.                   (setq lil (cons (list (car ips) (car (caddr ips))) lil))
  369.                   (setq lil (cons (list (car ips) (car (cadr ips))) lil))
  370.                 )
  371.                 ( t
  372.                   (setq lil (cons (list (car ips) (car (cadr ips))) lil))
  373.                   (setq lil (cons (list (car ips) (car (caddr ips))) lil))
  374.                 )
  375.               )
  376.             )
  377.             (setq ang (angle (car ips) (inters (caar tt) (cadar tt) (caadr tt) (cadadr tt) nil)))
  378.             (setq lstt (cons (list (car ips) ang (car tt) (cadr tt)) lstt))
  379.           )
  380.         )
  381.         (setq flag t)
  382.         (if (not k)
  383.           (setq k 1)
  384.           (setq k (1+ k))
  385.         )
  386.         (if (= k 1)
  387.           (setq tl (vl-remove (caddar lstt) tl))
  388.           (foreach tt tl
  389.             (if
  390.               (and
  391.                 (vl-some (function (lambda ( x ) (equal x (car tt) 1e-6))) (mapcar (function cadr) lil))
  392.                 (vl-some (function (lambda ( x ) (equal x (cadr tt) 1e-6))) (mapcar (function cadr) lil))
  393.               )
  394.               (setq tl (vl-remove tt tl))
  395.             )
  396.           )
  397.         )
  398.         (setq t1 (car tl))
  399.         (setq t2 (last tl))
  400.         (setq ipss nil)
  401.         (setq ipss (searchipss lst))
  402.         (if ipss
  403.           (if (setq lilxa (processlil t1 t2 ipss (cadar lstt)))
  404.             (setq lil (append (car lilxa) lil) ang (cadr lilxa))
  405.           )
  406.         )
  407.         (if
  408.           (or
  409.             (= k (length pl))
  410.             (vl-every (function (lambda ( x ) (vl-some (function (lambda ( y ) (equal x y 1e-6))) (mapcar (function cadr) lil)))) pl)
  411.           )
  412.           (setq done t)
  413.         )
  414.       )
  415.       (unique lil)
  416.     )
  417.   )
  418.  
  419.   (or (and cad doc alo spc) (vl-load))
  420.   (while (= 8 (logand 8 (getvar (quote undoctl))))
  421.     (if (not (vl-cmdf "_.UNDO" "_E"))
  422.       (if doc
  423.         (vla-endundomark doc)
  424.       )
  425.     )
  426.   )
  427.   (if (not (vl-cmdf "_.UNDO" "_BE"))
  428.     (if doc
  429.       (vla-startundomark doc)
  430.     )
  431.   )
  432.   (prompt "\nPick closed polygonal LWPOLYLINE on unlocked layer...")
  433.   (if (setq s (ssget "_+.:E:S:L" (list (cons 0 "LWPOLYLINE") (cons -4 "&=") (cons 70 1) (cons -4 "<not") (cons -4 "<>") (cons 42 0.0) (cons -4 "not>"))))
  434.     (progn
  435.       (setq ti (car (_vl-times)))
  436.       (setq lw (ssname s 0))
  437.       (vlax-invoke (vlax-ename->vla-object lw) (quote offset) -1e-3)
  438.       (setq lwi (entlast))
  439.       (if (> (vlax-curve-getarea lwi) (vlax-curve-getarea lw))
  440.         (progn
  441.           (rlw lw)
  442.           (entdel lwi)
  443.           (vlax-invoke (vlax-ename->vla-object lw) (quote offset) -1e-3)
  444.           (setq lwi (entlast))
  445.         )
  446.       )
  447.       (setq pl (mapcar (function cdr) (vl-remove-if (function (lambda ( x ) (/= (car x) 10))) (entget lw))))
  448.       (setq pli (mapcar (function cdr) (vl-remove-if (function (lambda ( x ) (/= (car x) 10))) (entget lwi))))
  449.       (while (not (equal (car pl) (car pli) 0.1))
  450.         (setq pli (append (cdr pli) (list (car pli))))
  451.       )
  452.       (setq tl (mapcar (function (lambda ( a b ) (list a b))) pl (append (cdr pl) (list (car pl)))))
  453.       (setq utl (unioncollinearplaneprints tl))
  454.       (setq lst (mapcar (function (lambda ( a b c d ) (list a (angle a b) c d))) pl pli (cons (last tl) (reverse (cdr (reverse tl)))) tl))
  455.       (setq llst lst)
  456.       (while (< att 3)
  457.         (if (not att)
  458.           (setq att 1)
  459.           (setq att (1+ att))
  460.         )
  461.         (setq lst llst)
  462.         (setq lil (process lst att))
  463.         (if (= att 1)
  464.           (setq lil1 lil)
  465.           (setq lil2 lil)
  466.         )
  467.       )
  468.       (if (> (length lil1) (length lil2))
  469.         (setq lil lil1)
  470.         (setq lil lil2)
  471.       )
  472.       (foreach li lil
  473.         (if (and (car li) (cadr li) (not (equal (car li) (cadr li) 1e-6)))
  474.           (entmake (list (cons 0 "LINE") (cons 10 (car li)) (cons 11 (cadr li))))
  475.         )
  476.       )
  477.     )
  478.   )
  479.   (*error* nil)
  480. )
  481.  

Regards, stay well and happy (coding)...
M.R.
« Last Edit: January 28, 2024, 12:03:31 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #276 on: February 03, 2024, 10:21:40 PM »
I've compiled *.lsp files packed in .\2D\ribarm\...

*.des files are for BricsCAD
*.VLX files are for AutoCAD

It is actually just slightly faster then before, so I am hoping that someone working with *.arx, *.brx or *.dll will jump in and give it a try for those files that are compiled... 2droof-final.lsp does not need conversion as it's running fast enough that only searching errn, errm combination is unknown, but when it finds it - it's superfast...
Routines packed in *.ZIP you can find here : https://www.theswamp.org/index.php?topic=41837.msg619616#msg619616

So long from me, thanks in advance, M.R.
« Last Edit: March 04, 2024, 02:16:31 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #277 on: February 22, 2024, 11:44:14 AM »
I am pushing this topic from bottom to top... I said thanks in advance in hope that someone may come to solution with *.arx, *.brx, or *.dll...

EDIT : Meanwhile, I've removed my poor attempts and left only those things that are good... I've managed to speed up just slightly : roof2d-new-new-new-nn.lsp by changing (if) into (cond) statements and my last one is called : roof2d-new-new-new-nnn.lsp...
So basically I want speeding up even more faster : roof2d-new-new-new-nnn.lsp by using Dot Net or Object Arx... Also I want this if it's possible with : roof2d-new-new-solutions.lsp, but only if it doesn't disturb translator as it's even more complex than roof2d-new-new-new-nnn.lsp

Regards, M.R.
« Last Edit: February 24, 2024, 07:50:32 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #278 on: February 29, 2024, 09:19:47 AM »
I've run on example which it couldn't solve with previous release... I've fixed it and changed names of main files... Now they are :

- roof2d-new-nn.lsp (if variant)
- roof2d-new-nnn.lsp (cond (= t t) variant)
- roof2d-new-nnnn.lsp (cond t variant)
- roof2d-new-solutions.lsp (cond (= t t) variant)
- roof2d-new-solutions-n.lsp (cond t variant)
Those routines that can solve roof2d-mistake.dwg
And there are also old ones that can solve almost everything else (99%) - except roof2d-mistake.dwg
They start with :
- roof2d-new-new-*.lsp

In archive there you can find *.des and *.VLX of these mentioned *.lsp files...

So long from me,
Regards, stay well and happy...
M.R.

EDIT : Additional *.dwg for testing is posted here : https://www.theswamp.org/index.php?topic=59312.msg619513#msg619513
« Last Edit: March 03, 2024, 07:23:59 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #279 on: February 29, 2024, 07:08:17 PM »
I've updated roof2d*.lsp with just roof2d.lsp, roof2d.des and roof2d.VLX... It should solve everything, but I had to slow it down with testing subs for checking weather solution is good or bad... If it's bad, it restarts and finish as good... That is double timing if even more as it creates duplicate lines which are upon finish OVERKILL-ed...

Regards, M.R.

P.S. Can someone look at it and remove duplication, so that OVERKILL line doesn't need to be neccessary...
« Last Edit: April 16, 2024, 08:08:18 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #280 on: March 03, 2024, 11:01:52 AM »
In previous post are my latest revisions, and assuming to testing results posted on DWG here : https://www.theswamp.org/index.php?topic=59312.msg619513#msg619513 , my (cond) version is faster than (if) version, so I'd like that you download *.ZIP in previous post and translate "roof2d-new-nnnn.lsp" and if there are time (it works desiring speed) to translate "roof2d-new-solutions-n.lsp" into adequate *.arx, or *.brx, or *.dll for versions of AutoCAD 2022 and BricsCAD V23...

This all is just my humble request if someone have time or want to earn some reputation here on theswamp.org...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #281 on: March 05, 2024, 01:48:35 PM »
Change of plan...
As far as I could test my versions, I've found too many lacks... So now request is to work with proved as good and that is chlh_jd's code that is checking errn and errm - loops until it finds correct solution... So we need translation "2droof-final.lsp" into corresponding *.arx, *.brx or *.dll...
You can see where mistakes in calculation with my versions are in this testing DWG and I suggest strongly that you download it as you should have something for checking... Link : https://www.theswamp.org/index.php?topic=59312.msg619513#msg619513

Regards,
M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3255
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #282 on: March 05, 2024, 03:03:14 PM »
I've made slight changes for person who download it lastly - there was 1 download...
Sorry, I can't test and correct so quickly...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2132
  • class keyThumper<T>:ILazy<T>
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #283 on: March 05, 2024, 03:51:44 PM »
I downloaded the drawing and the code.
Haven't looked at the code.

The times shown on the 'reasonably shaped' profiles is faster than I'd expected.
The times for the complex profiles is still pretty good, in my opinion.

Just how fast should these profiles be solved, in your expectation ?

The average breathing rate for healthy humans is between 12 and 20 breaths per minute
At a mean of 16 that is 3,750 milliseconds per breath.

If a program takes 3 breaths is it slow or is the problem data complicated ?

If it performs 7 times in one breath, is the program fast or is the problem data simple ?

If it fails, does the speed matter ?

Regards,
« Last Edit: March 05, 2024, 04:11:47 PM by kdub_nz »
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #284 on: March 05, 2024, 06:43:45 PM »
Agree with Kdub_nz what is fast ?

A task for a client 3 hours manual edit, first go 20 minutes, current version 2 minutes for same task, time includes popping Alert messages so user can see its working, 1000+ objects 5 steps. Alerts about 20 seconds apart. Could do acet progress bar but its fast enough.

A typical house is what maybe 8 roof panels max, mine only has 4. Your code would be almost instant at that level.

A man who never made a mistake never made anything