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

0 Members and 1 Guest are viewing this topic.

#### highflyingbird

• Bull Frog
• Posts: 415
• Later equals never.
##### ==={Challenge}===Find the ridge lines of sloped roof
« on: May 27, 2012, 09:53:28 PM »
Given a closed polyline, To find the ridge lines of sloped roof, suppose if  every side  has the same slope.

I am a bilingualist,Chinese and Chinglish.

#### Serge J. Gianolla

• Guest
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #1 on: May 27, 2012, 10:54:25 PM »

#### Lee Mac

• Seagull
• Posts: 12895
• London, England
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #2 on: May 28, 2012, 06:42:50 AM »
I have a LISP solution which I believe yields the correct straight skeleton result for 90% of cases, but have not released it as freeware:

Some more examples:

« Last Edit: May 28, 2012, 02:01:57 PM by Lee Mac »

#### highflyingbird

• Bull Frog
• Posts: 415
• Later equals never.
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #3 on: May 28, 2012, 07:00:48 AM »
I have a LISP solution which I believe yields the correct straight skeleton result for 90% of cases, but have not released it as freeware:
..
I am a bilingualist,Chinese and Chinglish.

#### Krushert

• Seagull
• Posts: 13679
• FREE BEER Tomorrow!!
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #4 on: May 28, 2012, 07:41:47 AM »
Not to be a party pooper.  But I only about the 15% buildings I do have a consistant pitch thus having the ridge line at the same height.

My architects like to have a roof have the following artistic charater and charming features:
• change the pitch
• have differnt heights for the ridge
• have different heights for the eaves
• have wierd things happen at the interesction of rakes and eaves.
• all of the @#\$%!  *&^%!  %^&\$\$#^ above.

:pissed:
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

#### CAB

• Global Moderator
• Seagull
• Posts: 10401
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #5 on: May 28, 2012, 09:00:44 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### CAB

• Global Moderator
• Seagull
• Posts: 10401
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #6 on: May 28, 2012, 09:15:14 AM »
Current project. Roof ridge is not correct but close.
It is a remodel so I don't need it to be correct.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### Krushert

• Seagull
• Posts: 13679
• FREE BEER Tomorrow!!
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #7 on: May 28, 2012, 09:39:10 AM »
Current project. Roof ridge is not correct but close.
It is a remodel so I don't need it to be correct.
Holly Batman and I thought I had it bad!  We do a lot of wood framed apartment buildings so little more consistency before a change in a roof plane.  I forgot about McMansions.

Do you usually the document the plate height on the roof plan?  I kind a like that.
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

#### CAB

• Global Moderator
• Seagull
• Posts: 10401
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #8 on: May 28, 2012, 10:38:28 AM »
Plate height usually appear on the framing plan in the form of different hatches on the walls (plan view).
If it gets too complicated I provide a separate sheet just for plate heights.
The roof plan as you see above usual ends up as a 1/8 scale on the framing plan if there is room.
So at 1/8 scale it might be tough to see the text but I like that idea.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### ribarm

• Gator
• Posts: 3185
• Marko Ribar, architect
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #9 on: May 31, 2012, 12:04:22 PM »
Here is mine version (nobody posted code ) and as I am not real programmer as Lee, it's quite risky to be used... With some complex plines it can make quite mess, but on the other hand maybe someone can use it as it makes construction of roof solution... I just don't know how to make it better and as Lee won't post his solution at least I tried...

Code - Auto/Visual Lisp: [Select]
1. (defun pll (pl / K MSP PLA PLAO PLO PLOPTLST PLPTLST PTT PTTLST PTTLSTN DST VAR) (vl-load-com)
2.   (setq pla (vlax-ename->vla-object pl))
3.   (if (vl-catch-all-error-p (setq var (vl-catch-all-apply 'vla-offset (list pla -1e-3)))) (setq plao nil) (setq plao (car (vlax-safearray->list (vlax-variant-value var)))))
4.   (if plao (setq plo (vlax-vla-object->ename plao)))
5.   (if (> (cdr (assoc 90 (entget pl))) 2)
6.       (mapcar '(lambda (x) (if (eq (car x) 10) (setq plptlst (cons (cdr x) plptlst)))) (entget pl))
7.       (setq plptlst (reverse plptlst))
8.     )
9.   )
10.   (if plo
11.       (mapcar '(lambda (x) (if (eq (car x) 10) (setq ploptlst (cons (cdr x) ploptlst)))) (entget plo))
12.       (setq ploptlst (reverse ploptlst))
13.       (entdel plo)
14.     )
15.   )
16.   (setq k -1)
17.   (if ploptlst
18.       (repeat (length plptlst)
19.         (setq k (1+ k))
20.         (if (eq k (- (length plptlst) 1))
21.           (setq ptt (inters (nth k plptlst) (nth k ploptlst) (nth 0 plptlst) (nth 0 ploptlst) nil))
22.           (setq ptt (inters (nth k plptlst) (nth k ploptlst) (nth (+ k 1) plptlst) (nth (+ k 1) ploptlst) nil))
23.         )
24.         (if (and ptt (eq k (- (length plptlst) 1))) (setq pttlst (cons (distance (nth 0 plptlst) ptt) pttlst)))
25.         (if (and ptt (not (eq k (- (length plptlst) 1)))) (setq pttlst (cons (distance (nth k plptlst) ptt) pttlst)))
26.         (if (and ptt (< k (- (length plptlst) 1))) (setq pttlst (cons (distance (nth (+ k 1) plptlst) ptt) pttlst)))
27.       )
28.       (setq pttlstn (vl-sort pttlst '(lambda (a b) (< a b))))
29.       (setq dst (car pttlstn))
30.       (setq k -1)
31.       (repeat (length plptlst)
32.         (setq k (1+ k))
33.         (if (eq k (- (length plptlst) 1))
34.           (setq ptt (inters (nth k plptlst) (nth k ploptlst) (nth 0 plptlst) (nth 0 ploptlst) nil))
35.           (setq ptt (inters (nth k plptlst) (nth k ploptlst) (nth (+ k 1) plptlst) (nth (+ k 1) ploptlst) nil))
36.         )
37.         (if (and ptt (not (eq k (- (length plptlst) 1))) (or (eq (distance (nth k plptlst) ptt) dst) (eq (distance (nth (+ k 1) plptlst) ptt) dst)))
38.             (setq p ptt)
39.             (vla-addline msp (vlax-3d-point (nth k plptlst)) (vlax-3d-point ptt))
40.             (vla-addline msp (vlax-3d-point (nth (+ k 1) plptlst)) (vlax-3d-point ptt))
41.           )
42.           (if (and ptt (eq k (- (length plptlst) 1)) (or (eq (distance (nth k plptlst) ptt) dst) (eq (distance (nth 0 plptlst) ptt) dst)))
43.               (setq p ptt)
44.               (vla-addline msp (vlax-3d-point (nth k plptlst)) (vlax-3d-point ptt))
45.               (vla-addline msp (vlax-3d-point (nth 0 plptlst)) (vlax-3d-point ptt))
46.             )
47.           )
48.         )
49.       )
50.     )
51.   )
52. )
53.
54. (defun kr (plin / pold plinn pldxf plinptlst)
55.   (setq pold p)
56.   (vl-cmdf "_.offset" "t" plin p "")
57.   (setq plin (entlast))
58.   (setq pldxf (entget plin))
59.   (mapcar '(lambda (x) (if (eq (car x) 10) (setq plinptlst (cons (cdr x) plinptlst)))) pldxf)
60.   (setq plinptlst (reverse plinptlst))
61.   (setq plinptlst (acet-list-remove-duplicates plinptlst 1e-6))
62.   (entdel plin)
63.   (setq plinn (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline")
64.                                       (cons 90 (length plinptlst))
65.                                      '(70 . 1)
66.                                 )
67.                                 (mapcar '(lambda ( x ) (cons 10 x)) plinptlst)
68.                                 (list '(210 0.0 0.0 1.0))
69.                         )
70.               )
71.   )
72.   (pll plinn)
73.   (if (not (equal pold p 1e-8)) (kr plinn))
74. )
75.
76. (defun c:kr (/ pl)
77.   (setq pl (car (entsel "\nPick 2d polyline")))
78.   (pll pl)
79.   (kr pl)
80.   (princ)
81. )
82.

Regards, M.R.
« Last Edit: June 02, 2012, 06:57:24 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

#### ribarm

• Gator
• Posts: 3185
• Marko Ribar, architect
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #10 on: June 02, 2012, 08:21:12 AM »
As this is complicated to program, I watched this video and suddenly everything revealed to be simply built-in AutoCAD...

This example will surely undercut Lee's business with the code selling... Maybe Lee would change his mind and post the code for learning purposes of us that don't know how to create *.lsp routine for this...

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

#### highflyingbird

• Bull Frog
• Posts: 415
• Later equals never.
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #11 on: June 02, 2012, 09:40:52 AM »
This example will surely undercut Lee's business with the code selling... Maybe Lee would change his mind and post the code for learning purposes of us that don't know how to create *.lsp routine for this...

ribarm,excellent,I will take some time to study your code!
I am a bilingualist,Chinese and Chinglish.

#### CAB

• Global Moderator
• Seagull
• Posts: 10401
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #12 on: June 02, 2012, 11:31:44 AM »
LeeMac has invested considerable time and effort in learning to code well. I think he has every right
to recoup something for his investment.  He has shared his talent freely in many threads so I feel
he has given plenty to our community.

My 2cents
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970

#### chlh_jd

• Guest
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #13 on: June 03, 2012, 06:34:02 AM »
LeeMac has invested considerable time and effort in learning to code well. I think he has every right
to recoup something for his investment.  He has shared his talent freely in many threads so I feel
he has given plenty to our community.
Me too .

#### RGUS

• Newt
• Posts: 106
##### Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #14 on: June 03, 2012, 04:59:32 PM »
I have a LISP solution which I believe yields the correct straight skeleton result for 90% of cases, but have not released it as freeware:

Some more examples:

Awesome Lee... so where does one purchase such a cool bit of code?