Author Topic: entmake cylindrical HELIX  (Read 2202 times)

0 Members and 1 Guest are viewing this topic.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
entmake cylindrical HELIX
« on: February 09, 2016, 10:08:07 PM »
I have little unusual question/challenge... I want to entmake or create cylindrical HELIX with command through ALISP knowing start/end points on cylinder body and have radius of cylinder or it's WCS origin center point... Start/end points on body may be with different elevations and start point may be once lower then end point, or opposite start point may be higher then end point - then HELIX is going opposite direction... Also if start/end points are at the same elevations then I want to create appropriate ARC entity through entmake-command... For this task you may choose random data for debugging, but you must specify base point of cylinder in WCS and provide correct points data on body of cylinder for start/end points...

So lets see if someone can do it - I find HELIX command pretty complicated in such situations and I think that when routine is finished it may be useful while working in *CAD...

P.S. You must take in consideration that routine should provide both solution HELIXES or ARCS on both sides of cylinder body...

Thanks for your reply in advance, M.R.
« Last Edit: February 09, 2016, 10:28:40 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: entmake cylindrical HELIX
« Reply #1 on: February 10, 2016, 01:18:21 AM »
I have something, but only solution for CCW start/end point direction specification - so one HELIX/ARC...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:mcylhelix-arc ( / o p r ci p1 a1 h1 p2 a2 h2 )
  2.   (alert "Start/end points on cylindeer body must be specified in CCW direction...")
  3.   (if (or (eq (getvar 'worlducs) 0) (not (equal (getvar 'viewdir) '(0.0 0.0 1.0) 1e-8)))
  4.     (progn
  5.       (command "_.UCS" "_W")
  6.       (command "_.PLAN" "")
  7.     )
  8.   )
  9.   (setq o (mapcar '+ '(0.0 0.0) (getpoint "\nPick or specify center of cylinder : ")))
  10.   (setq p (mapcar '+ '(0.0 0.0) (getpoint o "\nPick or specify radius of cylinder : ")))
  11.   (setq r (distance o p))
  12.   (setq ci (entmakex (list '(0 . "CIRCLE") (cons 10 o) (cons 40 r) '(62 . 1))))
  13.   (setq p1 (getpoint o "\nPick or specify angle of first point on cylinder body : "))
  14.   (setq a1 (angle o p1))
  15.   (setq h1 (getdist "\nPick or specify elevation of first point on cylinder body : "))
  16.   (setq p1 (append (polar o a1 r) (list h1)))
  17.   (setq p2 (getpoint o "\nPick or specify angle of second point on cylinder body : "))
  18.   (setq a2 (angle o p2))
  19.   (setq h2 (getdist "\nPick or specify elevation of second point on cylinder body : "))
  20.   (setq p2 (append (polar o a2 r) (list h2)))
  21.   (cond
  22.     ( (equal h1 h2 1e-8)
  23.       (command "_.ARC" "_non" p1 "_C" "_non" (append o (list h1)) "_non" p2)
  24.     )
  25.     ( (equal a1 a2 1e-8)
  26.       (command "_.LINE" "_non" p1 "_non" p2 "")
  27.     )
  28.     ( t
  29.       (command "_.UCS" "_3P" "_non" (if (> h2 h1) (append o (list h1)) (append o (list h2))) "_non" (if (> h2 h1) p1 p2) "")
  30.       (command "_.HELIX" "_non" '(0.0 0.0 0.0) r r "_W" (if (> h2 h1) "CCW" "CW") "_T" (/ (if (> a2 a1) (- a2 a1) (- (+ a2 (* 2.0 pi)) a1)) (* 2.0 pi)) "_H" (* (abs (- h2 h1)) (/ (* 2.0 pi) (if (> a2 a1) (- a2 a1) (- (+ a2 (* 2.0 pi)) a1)))))
  31.       (command "_.UCS" "_P")
  32.     )
  33.   )
  34.   (entdel ci)
  35.   (princ)
  36. )
  37.  
« Last Edit: February 10, 2016, 01:48:03 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: entmake cylindrical HELIX
« Reply #2 on: February 10, 2016, 02:41:35 AM »
Here is something based on this... If you want to perforate 2d planar rectangular or 3d cylindrical wall/fence with circles obtained from triangulation in WCS plane...

I find it very useful especially if you use bridson algorithm posted by YMG...

Regards, M.R.

[EDIT: Reattached file - 3 downloads...]
« Last Edit: February 11, 2016, 01:01:53 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: entmake cylindrical HELIX
« Reply #3 on: February 10, 2016, 08:47:38 AM »
Or just projecting lines... If you wish, you can create TIN with VORONOI diagram based on bridson algorithm with YMG codes - Triang and bridson - triangulation should be performed in first WCS quadrant... Then leave only Voronoi, then remove outside regions, then explode them, then apply OVERKILL on exploded LINES, and finally apply this lisp posted here... You should get Voronoi on cylindrical shape... After that it's simple enough to apply sweep with unit circle on those HELIXES...

Here is code for sweep :
Code - Auto/Visual Lisp: [Select]
  1. (defun c:obl-c ( / unit *adoc* rad ci ss i curve sp ep cii ciix )
  2.  
  3.  
  4.   (defun unit ( v )
  5.     (if (not (equal v '(0.0 0.0 0.0) 1e-8))
  6.       (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v)
  7.     )
  8.   )
  9.  
  10.   (initget 7)
  11.   (setq rad (getdist "\nSpecify unit circle radius for sweep along curves : "))
  12.   (setq ci (entmakex (list '(0 . "CIRCLE") '(10 0.0 0.0 0.0) (cons 40 rad))))
  13.   (entdel ci)
  14.   (prompt "\nSelect curve entities to make sweeps with unit circle...")
  15.   (if (setq ss (ssget '((0 . "*POLYLINE,LINE,SPLINE,ARC,CIRCLE,ELLIPSE,HELIX"))))
  16.     (progn
  17.       (entdel ci)
  18.       (repeat (setq i (sslength ss))
  19.         (setq curve (ssname ss (setq i (1- i))))
  20.         (setq sp (vlax-curve-getstartpoint curve))
  21.         (setq ep (vlax-curve-getendpoint curve))
  22.         (setq cii (entmakex (vl-remove-if '(lambda ( x ) (vl-position x '(-1 5 330))) (entget ci))))
  23.         (setq ciix (entget cii))
  24.         (setq ciix (subst (cons 10 (trans sp 0 (unit (vlax-curve-getfirstderiv curve (vlax-curve-getstartparam curve))))) (assoc 10 ciix) ciix))
  25.         (setq ciix (subst (cons 210 (unit (vlax-curve-getfirstderiv curve (vlax-curve-getstartparam curve)))) (assoc 210 ciix) ciix))
  26.         (entupd (cdr (assoc -1 (entmod ciix))))
  27.         (command "_.SWEEP" cii "" curve)
  28.         (while (< 0 (getvar 'cmdactive)) (command ""))
  29.       )
  30.     )
  31.     (prompt "\nEmpty sel.set... Please select curve entity(ies) next time when routine is started again...")
  32.   )
  33.   (if (entget ci)
  34.     (entdel ci)
  35.   )
  36.   (vla-endundomark *adoc*)
  37.   (princ)
  38. )
  39.  

Regards, M.R.

[EDIT: Reattached file - 2 downloads...]
« Last Edit: February 11, 2016, 01:02:13 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ChrisCarlson

  • Guest
Re: entmake cylindrical HELIX
« Reply #4 on: February 10, 2016, 04:44:35 PM »
Whats the end goal? Make a 3d solid helix?

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: entmake cylindrical HELIX
« Reply #5 on: February 10, 2016, 10:22:37 PM »
Whats the end goal? Make a 3d solid helix?

The goal is to model 3d solid wall/fence in cylindrical shape with circle perforations - cone/circle engraved shapes, or with cylindrical helixes based on triangulation, or on Voronoi diagram, or something third constructed with lines placed in WCS plane...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube