Author Topic: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.  (Read 5345 times)

0 Members and 1 Guest are viewing this topic.

Q1241274614

  • Guest
( algorithm ) and point A to point B, in 3D FACE on shortest distance.

GP

  • Newt
  • Posts: 83
  • Vercelli, Italy
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #1 on: November 01, 2012, 02:04:44 PM »
I had done this lisp to draw a section line on a DTM (3Dfaces), creates a 3Dpoly on 3Dfaces.
Use 3Dfaces nonoverlapping.
Not very nice, but it works ...  :-)
« Last Edit: November 01, 2012, 02:07:48 PM by GP »

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #2 on: November 01, 2012, 02:18:34 PM »
I had done this lisp to draw a section line on a DTM (3Dfaces), creates a 3Dpoly on 3Dfaces.
Use 3Dfaces nonoverlapping.
Not very nice, but it works ...  :-)
I think this is not the corect solution.
The algorithm is simple as: unfold assembly, draw a straight line, fold back...
Well, this is the idea, but for many particular situations that "straight line" is not so straight.

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #3 on: November 01, 2012, 03:13:22 PM »
Here is my proof (see length of green 3Dpoly).

Q1241274614

  • Guest
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #4 on: November 01, 2012, 07:51:46 PM »
Thanks to GP ,Stefan,Stefan algorithm is on the. How to write effective calculation!
The algorithm is simple as: unfold assembly, draw a straight line, fold back...
« Last Edit: November 02, 2012, 08:19:25 AM by Q1241274614 »

Stefan

  • Bull Frog
  • Posts: 319
  • The most I miss IRL is the Undo button
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #5 on: November 02, 2012, 08:50:24 AM »
Use "align" command.

Q1241274614

  • Guest
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #6 on: November 02, 2012, 09:02:46 AM »
Use "align“,Not good!Geometry calculation of three sides and angles.

Q1241274614

  • Guest
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #7 on: November 02, 2012, 09:10:08 AM »
Then the intersection.

GP

  • Newt
  • Posts: 83
  • Vercelli, Italy
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #8 on: November 03, 2012, 11:35:02 AM »
I do not have time available to write code, use "align" command (as suggested by Stefan).

Q1241274614

  • Guest
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #9 on: November 05, 2012, 08:02:40 AM »
Is it right? There are geometric method, vector method... ,
1.According to the spatial curved surface point to start into a plane, computing intersection point length.
2.Each of the two triangles. In turn according to the common edge and length, calculate the space position.
3.Connection
« Last Edit: November 05, 2012, 08:24:42 AM by Q1241274614 »

Q1241274614

  • Guest
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #10 on: November 15, 2012, 04:33:56 AM »
help?

well20152016

  • Newt
  • Posts: 130
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #11 on: December 12, 2016, 11:42:56 PM »
Diagonal equality

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #12 on: December 13, 2016, 09:46:48 AM »
Only applicable on Stefan's example DWG when folded and unfolded 3DFACES are exact match - so this is no good for unfolding : http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/3d-faces-down-to-zero-level/m-p/5878805/highlight/true#M336186

Code - Auto/Visual Lisp: [Select]
  1. (defun c:foldline-foldunfold3dpolyline ( / unique unit online-p ss3df li 3dfli p1 p2 p3 p4 l1 l2 l3 l4 d1 d2 d3 d4 3dfsd 3dfsdl sp ep spp s3dfli s3df s3dflin np n3dfli n3dflin 3dfsdln 3df3d 3dfn-mp s3dfli3d n3dfli3d s3dp n3dp vertl k )
  2.  
  3.  
  4.   (defun unique ( l )
  5.     (if l (cons (car l) (unique (vl-remove-if '(lambda ( x ) (equal x (car l) 1e-6)) l))))
  6.   )
  7.  
  8.   (defun unit ( v )
  9.     (if (not (equal v '(0.0 0.0 0.0) 1e-8))
  10.       (mapcar '(lambda ( x ) (/ x (distance '(0.0 0.0 0.0) v))) v)
  11.     )
  12.   )
  13.  
  14.   (defun online-p ( p p1 p2 )
  15.     (equal (distance p1 p2) (+ (distance p1 p) (distance p p2)) 1e-6)
  16.   )
  17.  
  18.   (prompt "\nSelect unfolded or folded 3DFACES...")
  19.   (setq ss3df (ssget '((0 . "3DFACE"))))
  20.   (setq li (car (entsel "\nPick LINE or 3DPOLYLINE that passes through unfolded or folded 3DFACES...")))
  21.   (setq 3dfli (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss3df))))
  22.   (foreach 3df 3dfli
  23.     (mapcar 'set '(p1 p2 p3 p4) (vl-remove 'nil (mapcar '(lambda ( x ) (if (vl-position (car x) '(10 11 12 13)) (cdr x))) (entget 3df))))
  24.     (mapcar 'set '(l1 l2 l3 l4) (list (list p1 p2) (list p2 p3) (list p3 p4) (list p4 p1)))
  25.     (mapcar 'set '(d1 d2 d3 d4) (list (distance p1 p2) (distance p2 p3) (distance p3 p4) (distance p4 p1)))
  26.     (setq 3dfsd (list (list d1 l1) (list d2 l2) (list d3 l3) (list d4 l4)))
  27.     (setq 3dfsdl (cons 3dfsd 3dfsdl))
  28.   )
  29.   (setq spp sp k 0)
  30.   (while (not (equal np ep 1e-6))
  31.     (setq k (1+ k))
  32.     (vl-some '(lambda ( x )
  33.       (cond
  34.         ( (online-p sp (car (cadr (car x))) (cadr (cadr (car x))))
  35.           (setq s3dfli (car x))
  36.           (setq s3df x)
  37.         )
  38.         ( (online-p sp (car (cadr (cadr x))) (cadr (cadr (cadr x))))
  39.           (setq s3dfli (cadr x))
  40.           (setq s3df x)
  41.         )
  42.         ( (online-p sp (car (cadr (caddr x))) (cadr (cadr (caddr x))))
  43.           (setq s3dfli (caddr x))
  44.           (setq s3df x)
  45.         )
  46.         ( (online-p sp (car (cadr (cadddr x))) (cadr (cadr (cadddr x))))
  47.           (setq s3dfli (cadddr x))
  48.           (setq s3df x)
  49.         )
  50.       )
  51.       ) (setq 3dfsdl (vl-remove s3df 3dfsdl))
  52.     )
  53.     (setq s3dflin (list (car s3dfli) (list (car (cadr s3dfli)) sp (cadr (cadr s3dfli)))))
  54.     (if (= (cdr (assoc 0 (entget li))) "LINE")
  55.       (mapcar '(lambda ( x ) (if (inters sp ep (car (cadr x)) (cadr (cadr x))) (setq np (inters sp ep (car (cadr x)) (cadr (cadr x)))))) (vl-remove s3dfli s3df))
  56.     )
  57.     (if (wcmatch (cdr (assoc 0 (entget li))) "*POLYLINE")
  58.       (setq np (vlax-curve-getpointatparam li (float k)))
  59.     )
  60.     (mapcar '(lambda ( x ) (if (online-p np (car (cadr x)) (cadr (cadr x))) (setq n3dfli x))) (vl-remove s3dfli s3df))
  61.     (setq n3dflin (list (car n3dfli) (list (car (cadr n3dfli)) np (cadr (cadr n3dfli)))))
  62.     (setq 3dfsdln (cons (subst s3dflin s3dfli (subst n3dflin n3dfli s3df)) 3dfsdln))
  63.     (setq sp np)
  64.   )
  65.   (setq 3dfsdln (reverse 3dfsdln))
  66.   (prompt "\nSelect folded or unfolded 3DFACES (opposite than references 3DFACES)...")
  67.   (setq ss3df (ssget '((0 . "3DFACE"))))
  68.   (setq 3dfli (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss3df))))
  69.   (foreach 3df 3dfli
  70.     (mapcar 'set '(p1 p2 p3 p4) (vl-remove 'nil (mapcar '(lambda ( x ) (if (vl-position (car x) '(10 11 12 13)) (cdr x))) (entget 3df))))
  71.     (mapcar 'set '(l1 l2 l3 l4) (list (list p1 p2) (list p2 p3) (list p3 p4) (list p4 p1)))
  72.     (mapcar 'set '(d1 d2 d3 d4) (list (distance p1 p2) (distance p2 p3) (distance p3 p4) (distance p4 p1)))
  73.     (setq 3dfsd (list (list d1 l1) (list d2 l2) (list d3 l3) (list d4 l4)))
  74.     (setq 3dfsdl (cons 3dfsd 3dfsdl))
  75.   )
  76.   (setq sp spp)
  77.   (foreach 3dfn 3dfsdln
  78.     (vl-some '(lambda ( x )
  79.       (if
  80.         (and
  81.           (vl-some '(lambda ( y ) (equal (car (car x)) y 1e-6)) (mapcar 'car 3dfn))
  82.           (vl-some '(lambda ( y ) (equal (car (cadr x)) y 1e-6)) (mapcar 'car 3dfn))
  83.           (vl-some '(lambda ( y ) (equal (car (caddr x)) y 1e-6)) (mapcar 'car 3dfn))
  84.           (vl-some '(lambda ( y ) (equal (car (cadddr x)) y 1e-6)) (mapcar 'car 3dfn))
  85.         )
  86.         (setq 3df3d x)
  87.       )
  88.       ) 3dfsdl
  89.     )
  90.     (setq 3dfn-mp (vl-remove-if '(lambda ( x ) (null (caddr (cadr x)))) 3dfn))
  91.     (setq s3dfli (car (vl-remove-if-not '(lambda ( x ) (equal sp (cadr (cadr x)) 1e-6)) 3dfn-mp)))
  92.     (setq n3dfli (car (vl-remove-if '(lambda ( x ) (equal sp (cadr (cadr x)) 1e-6)) 3dfn-mp)))
  93.     (vl-some '(lambda ( x ) (if (equal (car x) (car s3dfli) 1e-6) (setq s3dfli3d x))) 3df3d)
  94.     (vl-some '(lambda ( x ) (if (equal (car x) (car n3dfli) 1e-6) (setq n3dfli3d x))) 3df3d)
  95.     (setq s3dp (mapcar '+ (car (cadr s3dfli3d)) (mapcar '* (unit (mapcar '- (cadr (cadr s3dfli3d)) (car (cadr s3dfli3d)))) (list (distance (car (cadr s3dfli)) sp) (distance (car (cadr s3dfli)) sp) (distance (car (cadr s3dfli)) sp)))))
  96.     (setq n3dp (mapcar '+ (car (cadr n3dfli3d)) (mapcar '* (unit (mapcar '- (cadr (cadr n3dfli3d)) (car (cadr n3dfli3d)))) (list (distance (car (cadr n3dfli)) (cadr (cadr n3dfli))) (distance (car (cadr n3dfli)) (cadr (cadr n3dfli))) (distance (car (cadr n3dfli)) (cadr (cadr n3dfli)))))))
  97.     (setq vertl (cons s3dp vertl) vertl (cons n3dp vertl))
  98.     (setq sp (cadr (cadr n3dfli)))
  99.   )
  100.   (setq vertl (unique (reverse vertl)))
  101.   (entmake
  102.     (list
  103.       '(0 . "POLYLINE")
  104.       '(100 . "AcDbEntity")
  105.       '(100 . "AcDb3dPolyline")
  106.       '(66 . 1)
  107.       '(10 0.0 0.0 0.0)
  108.       '(70 . 8)
  109.       '(210 0.0 0.0 1.0)
  110.     )
  111.   )
  112.   (foreach pt vertl
  113.     (entmake
  114.       (list
  115.         '(0 . "VERTEX")
  116.         '(100 . "AcDbEntity")
  117.         '(100 . "AcDbVertex")
  118.         '(100 . "AcDb3dPolylineVertex")
  119.         (cons 10 pt)
  120.         '(70 . 32)
  121.       )
  122.     )
  123.   )
  124.     (list
  125.       '(0 . "SEQEND")
  126.       '(100 . "AcDbEntity")
  127.     )
  128.   )
  129.   (princ)
  130. )
  131.  

P.S. Better ever than never...
Regards, M.R.
« Last Edit: February 04, 2017, 04:00:20 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

chapalee

  • Mosquito
  • Posts: 7
Re: ( algorithm ) and point A to point B, in 3D FACE on shortest distance.
« Reply #14 on: February 04, 2017, 02:31:16 AM »
Hi guys, how are you?

I would like to comment on an error in the lisp PROF_3DF_EN.LSP
The 3d polyline is not well projected.
If it could be corrected, I would appreciate it.
Also, if you could use the command in any view, it would be much better.

I attached a DWG file so they can see the error.

Thank you very much.