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

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #15 on: June 03, 2012, 05:11:20 PM »
BTW, This is the link to the old thread.
http://www.theswamp.org/index.php?topic=721.0
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.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #16 on: June 04, 2012, 06:58:04 AM »
Awesome Lee... so where does one purchase such a cool bit of code?

Thanks RGUS  :-)

The code isn't quite finished as yet, I've still to eradicate some minor bugs but I shall certainly inform you of its completion and availability when I've finished working on it.

Lee

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #17 on: June 04, 2012, 07:21:18 AM »
But Lee, isn't this the same as yours (used cheat from video I posted)... Only thing is one more input of inside polyline point...

Quote
THE CODE REMOVED DUE IT'S UNNECESSARY - HAVEN'T GIVE CORRECT RESULTS UNDER A2008... CHECK MY POST BELOW WITH CODE CORRECT FOR A2008->A2012...

M.R.
« Last Edit: June 04, 2012, 05:06:35 PM 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 #18 on: June 04, 2012, 08:23:00 AM »
Not working in ACAD2006 with simple rectangle.
Code: [Select]
Command: roof

Pick 2d polyline
Pick point inside 2d polyline
Enter choice (2D / 3D) : 2D
Unknown command "ROOF".  Press F1 for help.

Requires numeric distance, two points, or option keyword.


Unable to extrude the selected object.
Unknown command "ROOF".  Press F1 for help.
1 face found.


Modeling Operation Error:
     No solution for a vertex.
Unknown command "ROOF".  Press F1 for help.
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.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #19 on: June 04, 2012, 08:51:20 AM »
I am using A2008 and >... Can you upload your *.dwg with rectangle... Maybe cheat isn't functioning on A2006, but on my comps. it's working like charm...

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

:)

M.R. on Youtube

Faster

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #20 on: June 04, 2012, 09:12:59 AM »
But Lee, isn't this the same as yours (used cheat from video I posted)... Only thing is one more input of inside polyline point...

...
M.R.
Nice code!Thanks!

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #21 on: June 04, 2012, 09:56:45 AM »
Here is variant for A2008->A2012, and I suppose A2013...

Code - Auto/Visual Lisp: [Select]
  1. (defun ss=ss1-ss2 (ss1 ss2)
  2.   (acet-ss-remove ss2 ss1)
  3. )
  4.  
  5. (defun c:roof ( / ANG ANGG CH DELOB K LIN LINN OSM P P1 P2 PL PLL PP QAF S1 S2 SS SSS SSN VS)
  6.   (setq delob (getvar 'delobj))
  7.   (setq qaf (getvar 'qaflags))
  8.   (setq osm (getvar 'osmode))
  9.   (setvar 'osmode 0)
  10.   (setq pll (entsel "\nPick 2d polyline with straight segments"))
  11.   (setq pl (car pll))
  12.   (setq pp (cadr pll))
  13.   (setq p (getpoint "\nPick point inside 2d polyline"))
  14.   (setq p (list (car p) (cadr p) 1e-3))
  15.   (initget 7 "2D 3D")
  16.   (setq ch (getkword "\nEnter choice (2D / 3D) : "))
  17.   (if (eq ch "2D")
  18.     (progn
  19.       (setq s1 (ssget "_X" '((0 . "3DSOLID"))))
  20.       (vl-cmdf "_.regen")
  21.       (vl-cmdf "_.zoom" "v")
  22.       (setq vs (getvar 'viewsize))
  23.       (vl-cmdf "_.zoom" "p")
  24.       (setvar 'delobj 0)
  25.       (vl-cmdf "_.extrude" pl "" "t" 75.0 1e-3 "")
  26.       (vl-cmdf "_.solidedit" "f" "m" p "" (list 0.0 0.0 0.0) (list 0.0 0.0 vs) "" "")
  27.       (vl-cmdf "_.solidedit" "b" "p" (entlast) "" "")
  28.       (setq s2 (ssget "_X" '((0 . "3DSOLID"))))
  29.       (setq ss (ss=ss1-ss2 s2 s1))
  30.       (vl-cmdf "_.erase" ss "r" pp "")
  31.       (vl-cmdf "_.explode" (ssname (ssget pp '((0 . "3DSOLID"))) 0) "")
  32.       (setvar 'qaflags 1)
  33.       (vl-cmdf "_.explode" (ssget "_P") "")
  34.       (setq ss (ssget "_P"))
  35.       (setq sss (ssadd))
  36.       (repeat (setq ssn (sslength ss))
  37.         (setq lin (ssname ss (setq ssn (1- ssn))))
  38.         (if (and (eq (caddr (cdr (assoc 10 (entget lin)))) 0.0) (eq (caddr (cdr (assoc 11 (entget lin)))) 0.0))
  39.           (entdel lin)
  40.           (progn
  41.             (setq p1 (cdr (assoc 10 (entget lin))))
  42.             (setq p2 (cdr (assoc 11 (entget lin))))
  43.             (setq p1 (list (car p1) (cadr p1) 0.0))
  44.             (setq p2 (list (car p2) (cadr p2) 0.0))
  45.             (entmod (subst (cons 10 p1) (assoc 10 (entget lin)) (entget lin)))
  46.             (setq linn (entupd (cdr (assoc -1 (entmod (subst (cons 11 p2) (assoc 11 (entget lin)) (entget lin)))))))
  47.             (ssadd linn sss)
  48.           )
  49.         )
  50.       )
  51.       (repeat (setq ssn (sslength sss))
  52.         (setq lin (ssname sss (setq ssn (1- ssn))))
  53.         (repeat (setq k ssn)
  54.           (setq linn (ssname sss (setq k (1- k))))
  55.           (if (or (and (equal (assoc 10 (entget lin)) (assoc 10 (entget linn)) 1e-6) (equal (assoc 11 (entget lin)) (assoc 11 (entget linn)) 1e-6)) (and (equal (assoc 10 (entget lin)) (assoc 11 (entget linn)) 1e-6) (equal (assoc 11 (entget lin)) (assoc 10 (entget linn)) 1e-6)))
  56.             (entdel lin)
  57.           )
  58.         )
  59.       )
  60.     )
  61.     (progn
  62.       (setq s1 (ssget "_X" '((0 . "3DSOLID"))))
  63.       (setvar 'delobj 0)
  64.       (setq ang (getreal "\nEnter angle of slope of roof (0 < ang < 90) : "))
  65.       (setq angg (- 90.0 ang))
  66.       (vl-cmdf "_.regen")
  67.       (vl-cmdf "_.zoom" "v")
  68.       (setq vs (getvar 'viewsize))
  69.       (vl-cmdf "_.zoom" "p")
  70.       (vl-cmdf "_.extrude" pl "" "t" angg 1e-3 "")
  71.       (vl-cmdf "_.solidedit" "f" "m" p "" (list 0.0 0.0 0.0) (list 0.0 0.0 vs) "" "")
  72.       (vl-cmdf "_.solidedit" "b" "p" (entlast) "" "")
  73.       (setq s2 (ssget "_X" '((0 . "3DSOLID"))))
  74.       (setq ss (ss=ss1-ss2 s2 s1))
  75.       (vl-cmdf "_.erase" ss "r" pp "")
  76.     )
  77.   )
  78.   (setvar 'delobj delob)
  79.   (setvar 'qaflags qaf)
  80.   (setvar 'osmode osm)
  81.   (princ)
  82. )
  83.  

M.R.
« Last Edit: June 12, 2012, 09:58:51 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

LE3

  • Guest
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #22 on: June 04, 2012, 10:10:52 AM »
Nothing new or deja voo? - dang! have been a long time - time pass fast indeed - and old thinkings become new ones.... nice to go back on time with this..... keep the good work swamp guys!!!!

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #23 on: June 04, 2012, 12:15:50 PM »
Nice to hear from you Luis.  8-)

MR I think the problem is with the extrude command in 2006.
Code: [Select]
Command: extrude

Current wire frame density:  ISOLINES=4
Select objects: 1 found

Select objects:

Specify height of extrusion or [Path]:  Specify second point:
Specify angle of taper for extrusion <0>: 45
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 #24 on: June 04, 2012, 01:17:21 PM »
Which One is right ?
« Last Edit: June 04, 2012, 01:28:23 PM by chlh_jd »

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #25 on: June 04, 2012, 01:47:36 PM »
Which One is right ?

The one on the left
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #26 on: June 04, 2012, 01:58:32 PM »
The one on the right has a "Dead Vally" (a flat valley). This is to be avoided but sometime can not.
When you can't get away from the situation you add a "Cricket"  8-)
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.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #27 on: June 05, 2012, 06:23:21 AM »
The code for roof finally revised... If you plan to use pline with arcs, I suggest segmentation... This one was by Lee Mac, and I just modified it to suite my needs... Thanks, Lee...

Code - Auto/Visual Lisp: [Select]
  1. ;; LWPolyline to Point List  -  Lee Mac
  2. ;; Returns a list of points describing the supplied LWPolyline
  3.  
  4. (defun LM:LWPoly->List ( ent n / der di1 di2 inc lst par rad )
  5.     (setq par 0)
  6.     (repeat (cdr (assoc 90 (entget ent)))
  7.         (if (setq der (vlax-curve-getsecondderiv ent par))
  8.             (if (equal der '(0.0 0.0 0.0) 1e-8)
  9.                 (setq lst (cons (vlax-curve-getpointatparam ent par) lst))
  10.                 (if
  11.                     (setq rad (distance '(0.0 0.0) (vlax-curve-getfirstderiv ent par))
  12.                           di1 (vlax-curve-getdistatparam ent par)
  13.                           di2 (vlax-curve-getdistatparam ent (1+ par))
  14.                     )
  15.                     (progn
  16.                         (setq inc (/ (- di2 di1) n))
  17.                         (while (< di1 di2)
  18.                             (setq lst (cons (vlax-curve-getpointatdist ent di1) lst)
  19.                                   di1 (+ di1 inc)
  20.                             )
  21.                         )
  22.                     )
  23.                 )
  24.             )
  25.         )
  26.         (setq par (1+ par))
  27.     )
  28.     lst
  29. )
  30.  
  31. ;; Test Function
  32.  
  33. (defun c:test ( / en lst n )
  34.     (while
  35.         (progn (setvar 'ERRNO 0) (setq en (car (entsel "\nSelect LWPolyline: ")))
  36.             (cond
  37.                 (   (= 7 (getvar 'ERRNO))
  38.                     (princ "\nMissed, try again.")
  39.                 )
  40.                 (   (eq 'ENAME (type en))
  41.                     (if (not (eq "LWPOLYLINE" (cdr (assoc 0 (entget en)))))
  42.                         (princ "\nInvalid Object Selected.")
  43.                     )
  44.                 )
  45.             )
  46.         )
  47.     )
  48.     (initget 6)
  49.     (setq n (getint "\nInput number of curved segments per arc <25> : "))
  50.     (if (null n) (setq n 25))
  51.     (if
  52.         (and en
  53.             (setq lst
  54.                 (mapcar
  55.                     (function (lambda ( x ) (trans x 0 en)))
  56.                     (LM:LWPoly->List en n)
  57.                 )
  58.             )
  59.         )
  60.         (entmakex
  61.             (append
  62.                 (list
  63.                     (cons 0 "LWPOLYLINE")
  64.                     (cons 100 "AcDbEntity")
  65.                     (cons 100 "AcDbPolyline")
  66.                     (cons 62 3)
  67.                     (cons 90 (length lst))
  68.                     (assoc 70 (entget en))
  69.                     (assoc 210 (entget en))
  70.                 )
  71.                 (mapcar '(lambda ( x ) (cons 10 x)) lst)
  72.             )
  73.         )
  74.     )
  75.     (princ)
  76. )
  77.  
  78.  

P.S. It can happen that CAD can't do extrude with taper angle, and then this roof.lsp fails, but in most cases with not to complex plines it works fine... Hope that CAB solved the issue with extrude in A2006 (don't have it installed, so I can't check my code)

Sincerely, M.R.
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 #28 on: June 05, 2012, 08:43:15 AM »
Changing to this extrude (vl-cmdf "_.extrude" pl "" 1000 45.0)
produces this:
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.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ==={Challenge}===Find the ridge lines of sloped roof
« Reply #29 on: June 05, 2012, 10:48:02 AM »
CAB, have you tried what's shown on this video... How is CAD behaving with SOLIDEDIT -> face -> move (vertex1 -> .xy vertex1 (z=1000)) in view ISOmetric (vpoint 1,1,1) ? Can it compute roof solution from your second example (picture) ? If not than routine will fail (contact Lee Mac) or witch I strongly suggest (A2006)=>A2008 or more up to date...

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

:)

M.R. on Youtube