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

0 Members and 8 Guests are viewing this topic.

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #90 on: June 03, 2014, 08:05:11 AM »
One more situation...

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

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #91 on: June 03, 2014, 10:24:21 PM »
Congratulations, GSLS... What is the problem then with revcloud? I also have issues with arced polylines... But solving my posted DWG, I hope situation is much better... chlh_jd, do I have to use my attached version to solve posted DWG "Another example" or do you also have some better approach? I'll attach my version of implemented your new solution - this is what I use finally for now... Thanks again... M.R.
[EDIT] : Attached one more case...
[EDIT] : LSP file reattached so that now if solution was found no need for overkill of ridges...
(4 downloads of old version)

Ribar , thank you for test . New version has fix "revcloud" bug and the case you post .

Don't devide arc so little , because  when the angle close to zero or close to pi , little angle deviation will cause large wrong point distance (like in the picture). To slove it , you must force angle pricision higher , such as 1e-9~1e-14, at the same time you should open vectexs equal eps , I don't sure (equal p1 p2 1e-3) is fit . To get  higher pricision , Recursive loop may be slow , perhaps  vlide is not suitable to do it .
This is why I used Lee Mac's function 'LM:Entity->Pointlist' , Of course, you cloud test all you used case and then set suitable angle and point pricision . Enjoy .


« Last Edit: June 03, 2014, 10:35:20 PM by chlh_jd »

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #92 on: June 04, 2014, 07:04:30 AM »
Preliminary add command mode .
Solid make failure , Need more improved work .
Enjoy .
« Last Edit: June 04, 2014, 07:33:06 AM by chlh_jd »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #93 on: June 04, 2014, 12:35:07 PM »
Preliminary add command mode .
Solid make failure , Need more improved work .
Enjoy .

chlh_jd, I use for modelling 2droof3d.lsp posted here on my previous posts... It works everything on my comp... Only thing you should say is that polyline should be scaled approx. 1000 times to avoid errors... I'll attach your code with my add of making ridges as single lines... This is prepared for 2droof3d.lsp... Thank you very much GSLS... I lost time checking what was the issue with errors and then I simply scaled and it worked... Congratulations on this code - it's very powerful...

Marko

[EDIT] : Reattached LSP to inform and prompt for scale factors if polyline wasn't scaled correctly...
( 11 downloads )
« Last Edit: June 05, 2014, 05:23:27 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #94 on: June 04, 2014, 01:03:59 PM »
chlh_jd
Awesome work  :)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #95 on: June 04, 2014, 09:24:53 PM »

chlh_jd, I use for modelling 2droof3d.lsp posted here on my previous posts... It works everything on my comp... Only thing you should say is that polyline should be scaled approx. 1000 times to avoid errors... I'll attach your code with my add of making ridges as single lines... This is prepared for 2droof3d.lsp... Thank you very much GSLS... I lost time checking what was the issue with errors and then I simply scaled and it worked... Congratulations on this code - it's very powerful...

Marko
Ribar , thank you for test every time , you're very welcome  :-)
I'm very impatient , so I don't let the sides to be take out 1000 times .

chlh_jd
Awesome work  :)
Thanks Alan  :-)

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #96 on: June 05, 2014, 04:37:14 AM »
chlh_jd,
Still more problems, see attached DWG (if you have time for coding - I am pleased with solution like it is, but...)...

M.R.
« Last Edit: June 05, 2014, 09:33:29 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #97 on: June 05, 2014, 11:02:26 AM »
chlh_jd,
Still more problems, see attached DWG (if you have time for coding - I am pleased with solution like it is, but...)...
M.R.
Ribar , thank you for test .
I must clear that , the whole routine I wrote used midle speeded-up thread , so it won't work for every case , rigorous treatment is before each added vertex  or  each closed side must be reordered Z-axis height, started from Z smaller , one step by one step .

First & third case , it's the error cause by first speeded-up used while loop instead of if in  foo or foo1 function  , change it like following code ,will take it .
Second case , it's the error : has wrong vectex in first joined , must add determine ---no cross the first can be closed side's neighbor next bisector .
Code - Auto/Visual Lisp: [Select]
  1. (defun foo  ()
  2.     (_getclosed)
  3.     (_getneighbor)
  4.     (while (and (< closed_n n) rnl)
  5.       (foreach ip  rnl
  6.         (if (< closed_n n)
  7.           (progn (_closeditself ip)
  8.                 ;| (while       (and (< closed_n n) (setq ip (_getclosedinfo bi fi)))
  9.                    (_closeditself ip))|;
  10.             (if (and (< closed_n n) (setq ip (_getclosedinfo bi fi)))
  11.                    (_closeditself ip));_not quickly launch         
  12.             )))
  13.       (_getclosed)
  14.       (_getneighbor))
  15.     )
  16. (defun foo1  ()
  17.     (_getnoclosdedpairinfo)
  18.     (while (and (< closed_n n) rnl)
  19.       (foreach ip  rnl
  20.         (if (< closed_n n)
  21.           (progn (_closeditself ip)
  22.                  ;|(while       (and (< closed_n n) (setq ip (_getclosedinfo bi fi)))
  23.                    (_closeditself ip))|;
  24.                 (if     (and (< closed_n n) (setq ip (_getclosedinfo bi fi)))
  25.                    (_closeditself ip))     
  26.                    )
  27.           ))
  28.       (_getnoclosdedpairinfo)))
  29.  

New version : add drawmode , error handle ... etc.
The errors Ribar take it out , 1st & 3rd has been solve , the second even not .

hanhphuc

  • Newt
  • Posts: 64
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #98 on: June 05, 2014, 12:19:14 PM »
hi chlh_jd,
i just notice small bug, assume we open a new drawing,
so layer "Proof" does not exist
(setvar "CLAYER" "Proof") ;rejected?
my suggest (if (tblsearch "LAYER" "proof") then etc..

Just curiuos, my VLIDE inspects the REAL _pi2: 1.5707963267948966192313216916395, it returns 1.5708. if (* _pi2 100000.); returns 157080.0 does it mean the precision reduced?

Thanx your amazing code  :-)
( apply 'equal "hp" "happy" "hạnh phúc" "ハッピー" "幸福" "행복" ) ; error: too many arguments

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #99 on: June 05, 2014, 01:25:42 PM »
Here, I've modified my version of your code... So now there are 2 versions - while version (2droof.lsp) and if version (2droof-t.lsp)... Sometime like in my posted DWG, maybe it's better to use while version... 2droof-t.lsp is newest one... Note that both are the same just one uses while, and other if...

Thanks...

[EDIT] : LSP files reattached to include newest mods by chlh_jd posted in Proof_6a.lsp
(2droof-t.lsp - 2 downloads)
« Last Edit: June 06, 2014, 02:48:44 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #100 on: June 05, 2014, 09:30:00 PM »
hi chlh_jd,
i just notice small bug, assume we open a new drawing,
so layer "Proof" does not exist
(setvar "CLAYER" "Proof") ;rejected?
my suggest (if (tblsearch "LAYER" "proof") then etc..

Just curiuos, my VLIDE inspects the REAL _pi2: 1.5707963267948966192313216916395, it returns 1.5708. if (* _pi2 100000.); returns 157080.0 does it mean the precision reduced?

Thanx your amazing code  :-)
Thanks hanhphuc .
It did need check layer , in my post lisp file proof_6.lsp has add it.

for test it's precision use (rtos (* _pi2 1000000) 2 10) --> "1570796.326794896"

Here, I've modified my version of your code... So now there are 2 versions - while version (2droof.lsp) and if version (2droof-t.lsp)... Sometime like in my posted DWG, maybe it's better to use while version... 2droof-t.lsp is newest one... Note that both are the same just one uses while, and other if...

Thanks...
For get the second case in your post dwgs , need determine neighbor first closed before add the vertex into RGL .
See the proof-6a.lsp
Code - Auto/Visual Lisp: [Select]
  1. ...
  2. ;; add first suitable intersections into it's side info , put them closed .
  3.        (setq closed_n 0)
  4.        (foreach s  il
  5.          (setq p (round (cadr s) 5))
  6.          (setq a (nth (format-i (- (caar s) 2) n) rgl)
  7.                c (nth (format-i (+ (caar s) 2) n) rgl))
  8.          ;; add whether the neighbor closed first .
  9.          (cond ((and (assoc 70 (nth (format-i (- (caar s) 2) n) rgl))
  10.                      (setq a (nth (format-i (1- (caar s)) n) rgl))
  11.                      (setq p0 (ray-int-line (pnth (cadar a))
  12.                                             (cdaar a)
  13.                                             (pnth (assoc 10 (cadr a)))
  14.                                             p))
  15.                      (not (equal p0 p *gsls_disfuzz*))))
  16.                ((and (assoc 70 (nth (format-i (+ (caar s) 2) n) rgl))
  17.                      (setq c (nth (format-i (1+ (caar s)) n) rgl))
  18.                      (setq p1 (ray-int-line (pnth (cadadr c))
  19.                                             (cdaadr c)
  20.                                             (pnth (assoc 10 (car c)))
  21.                                             p))
  22.                      (not (equal p1 p *gsls_disfuzz*))))
  23.                (t
  24.                 (if (not (setq i (vl-position p tl)))
  25.                   (setq tl (append tl (list p))
  26.                         zl (append zl (list (caddr s)))
  27.                         i  (1- (length tl))))
  28.                 (setq b         (nth (caar s) rgl)
  29.                       b1        (list (add-item i nil (car b))
  30.                                       (add-item i nil (cadr b))
  31.                                       (cons 70 1))
  32.                       rgl       (subst b1 b rgl)
  33.                       closed_n  (1+ closed_n)
  34.                       closed_il (cons (caar s) closed_il))
  35.                 ;;deal near side info
  36.                 (if (and (< closed_n n)
  37.                          (setq bi (suit-i (format-i (1- (caar s)) n) 1-))
  38.                          (setq fi (suit-i (cadar s) 1+))
  39.                          (/= bi fi))
  40.                   (setq a   (nth bi rgl)
  41.                         c   (nth fi rgl)
  42.                         p0  (nth (cdr (assoc 10 (car a))) pl)
  43.                         p1  (nth (cdr (assoc 10 (cadr a))) pl)
  44.                         p2  (nth (cdr (assoc 10 (car c))) pl)
  45.                         p3  (nth (cdr (assoc 10 (cadr c))) pl)
  46.                         an  (bisector2 p0 p1 p2 p3)
  47.                         a1  (list (car a) (add-item i an (cadr a)))
  48.                         c1  (list (add-item i an (car c)) (cadr c))
  49.                         rgl (subst a1 a rgl)
  50.                         rgl (subst c1 c rgl))))))
  51.        ;; deal has closed side .
  52.        (_closed)
  53. ...
  54.  

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #101 on: June 06, 2014, 02:52:19 AM »
chlh_jd, only if you have spare time... Look attached DWG... Hope I am not exaggerating...

(My posted LSP files updated and reattached in my previous post)

M.R.

[EDIT] : Attached one more...

Thanks...
« Last Edit: June 06, 2014, 05:00:17 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #102 on: June 06, 2014, 05:52:19 AM »
Just to mention, SOLUTION WASNT FINISHED.DWG is solvable through multiple attempts with error prompts from one of 2 versions - I think (while) 2droof.lsp...

Just uncomment these lines :
Code: [Select]
...
        (progn ;_force out routine ...
          (princ "\n ***Error*** : ...")
                                        (setq rgl nil)
                                        (setq errr (1+ errr))
                                        (setq pl (cons (last pl) (reverse (cdr (reverse pl)))))
                                        (if (and (< errr n) (not err))
                                        (start pl)
                                        )
...

And this - note (setq err t) :

Code: [Select]
...
    (while li
      (if
        (not
          (vl-some (function (lambda (x)
                               (or (and (equal (car x) (caar li) 1e-8)
                                        (equal (cadr x) (cadar li) 1e-8)
                                   )
                                   (and (equal (cadr x) (caar li) 1e-8)
                                        (equal (car x) (cadar li) 1e-8)
                                   )
                               )
                             )
                   )
                   (cdr li)
          )
        )
         (setq ll (cons (car li) ll))
      )
      (setq li (cdr li))
    )
    (foreach l ll
      (entmake (list
                 '(0 . "LINE")
                 (cons 10 (car l))
                 (cons 11 (cadr l))
                 '(62 . 1)
               )
      )
    )
                                        (setq err t)
  )
...

And this - note (setq errr 0) :
Code: [Select]
...
  ;;------------------------------------main routine ------------------------------;;

  (setq e (car (entsel "\nSelect a closed polygon :")))
                                        ;  (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
                                        ;  (vla-startundomark adoc)
  (setq #gsls_systemvar# (list "CMDECHO" "CLAYER"))
  (_svos) ;_undo begin , system variables store .
  (setq area (vlax-curve-getarea e))
  (if (< area 1000000000.0)
    (progn
      (setq scf (sqrt (/ 1000000000.5 area)))
      (alert "You must scale polyline - quitting")
      (prompt
        (strcat
          "\nYou must scale polyline with this factor to make routine compute ridges correctly : "
          (rtos scf 2 15)
        )
      )
      (prompt
        (strcat
          "\nInverse scale factor to return scaled solution back is : "
          (rtos (/ 1.0 scf) 2 15)
        )
      )
      (textscr)
      (exit)
    )
  )
  ;|
  (setq pl
  (mapcar (function cdr)
   (vl-remove-if-not (function (lambda (a) (= (car a) 10))) (entget e))))
  |;
  (setq pl (lm:entity->pointlist e) ;_for pl with arc
        pl (remove-same-pts pl 1e-6)
  ) ;_has doubles points in pl with arc
                                        (setq errr 0)
  (start pl)
  (_clos) ;_undo end , system variables reset . 
)
...

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

:)

M.R. on Youtube

chlh_jd

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #103 on: June 06, 2014, 06:28:23 AM »
chlh_jd, only if you have spare time... Look attached DWG... Hope I am not exaggerating...

(My posted LSP files updated and reattached in my previous post)

M.R.

[EDIT] : Attached one more...
Thanks...
Ribar , thank you for test  :-)
Although I have a better software to generate sloped roof, and this routine did take me a lot time  , but I still want to improve it  :-)

Just to mention, SOLUTION WASNT FINISHED.DWG is solvable through multiple attempts with error prompts from one of 2 versions - I think (while) 2droof.lsp...

Just uncomment these lines :

And this - note (setq err t) :

And this - note (setq errr 0) :
M.R.
Just like I've said ,if want to let it no catch any error , other word , to suit for any case (In fact, because there is precision in the calculation can not be done , I agree you that some case must be scaled , it also can be determine in the routine , after get the roof lines scaling back ) , It must give up some efficiency .
For this reason , I would like to deal crash side in the last part of the main routine  , insted of traversing each side over and over again .

I'll take some time to test your programe , but today is busy  , Sorry .
I post the V0.7 programe , it show how to solve some error in the last part and did get over the case in your post dwg .

Enjoy !
« Last Edit: June 06, 2014, 06:43:21 AM by chlh_jd »

ribarm

  • Gator
  • Posts: 3279
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #104 on: June 06, 2014, 06:55:00 AM »
Never mind, chlh_jd... When you have time only then continue with coding... Take care...

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

:)

M.R. on Youtube