Author Topic: CLOSEST POINT to a 3D SOLID  (Read 3058 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 720
CLOSEST POINT to a 3D SOLID
« on: September 03, 2023, 10:07:45 AM »
I need to select, using ENTSEL, a 3D SOLID. 

And i need to know
the POINT that LIES ON the SOLID
and which is the CLOSEST POINT to the SELECTION. 

The problem is that ENTSEL always
returns a POINT that has  ZETA = 0.00

And (OSNAP pt "nea")
seems that
DOESN'T WORK with a 3D SOLID

I need a (3DOSNAP pt "3dnea") !
« Last Edit: September 03, 2023, 11:08:39 PM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: CLOSEST POINT to a 3D SOLID
« Reply #1 on: September 03, 2023, 11:07:46 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun C:3DNEA ( / es pt )
  2.    (and
  3.       (setq es (entsel "\nselect object : ") )
  4.       (setq pt (cadr es) )
  5.       (setq pt (osnap pt "znea") )
  6.       (vl-cmdf "point" pt)
  7.    )
  8. )

and   (osnap pt "znea")   doesn't work as espected

I must however clarify that I am trying to find the closest point to the selection of a 3dsolid
that is contained in a block (that is not even scaled uniformly)

in the previous post I described the problem with a simplification
« Last Edit: September 03, 2023, 11:27:45 PM by domenicomaria »

ribarm

  • Gator
  • Posts: 3180
  • Marko Ribar, architect
Re: CLOSEST POINT to a 3D SOLID
« Reply #2 on: September 04, 2023, 08:00:47 AM »
You'll have to import your block to Rhino7, then there EXPLODE and save 3DSOLIDS as ACIS objects, then return to AutoCAD, use command ACISIN, point to a file, and you'll get 3DSOLIDS from non-uniformly scaled block... Then apply Daniel's arx for finding closest point to 3DSOLID, SURFACE, from some point in 3D SPACE...
Link : https://www.theswamp.org/index.php?topic=53008.msg607187#msg607187
Link : https://www.theswamp.org/index.php?topic=55516.0
« Last Edit: September 04, 2023, 08:18:32 AM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1447
  • Marco
Re: CLOSEST POINT to a 3D SOLID
« Reply #3 on: September 04, 2023, 08:49:15 AM »
Code: [Select]
(defun C:3DNEA ( / pt)
  (prompt "\nSelect object: ")
  (vl-cmdf "_.ID" "_NEA" pause)
  (setq pt (getvar "LASTPOINT"))
  (vl-cmdf "_.POINT" "_NONE" pt)
  (princ)
)

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: CLOSEST POINT to a 3D SOLID
« Reply #4 on: September 04, 2023, 09:25:13 AM »
You'll have to import your block to Rhino7, then there EXPLODE and save 3DSOLIDS as ACIS objects, then return to AutoCAD, use command ACISIN, point to a file, and you'll get 3DSOLIDS from non-uniformly scaled block... Then apply Daniel's arx for finding closest point to 3DSOLID, SURFACE, from some point in 3D SPACE...
Link : https://www.theswamp.org/index.php?topic=53008.msg607187#msg607187
Link : https://www.theswamp.org/index.php?topic=55516.0
... no Rhino, no external arx ...

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: CLOSEST POINT to a 3D SOLID
« Reply #5 on: September 04, 2023, 09:30:56 AM »
Code: [Select]
(defun C:3DNEA ( / pt)
  (prompt "\nSelect object: ")
  (vl-cmdf "_.ID" "_NEA" pause)
  (setq pt (getvar "LASTPOINT"))
  (vl-cmdf "_.POINT" "_NONE" pt)
  (princ)
)

Marco,
it does not recognize the outlines of a block which contains a 3dsolid,
and which is not uniformly scaled . . .

(it only works for evenly scaled blocks)

ribarm

  • Gator
  • Posts: 3180
  • Marko Ribar, architect
Re: CLOSEST POINT to a 3D SOLID
« Reply #6 on: September 04, 2023, 09:44:15 AM »
What if you try BBox.lsp posted here : https://www.theswamp.org/index.php?topic=58504.msg615927#msg615927...
Of course, you'll have to align UCS to your block prior running *.lsp...
Coloured lines, you'll have to redraw somehow...

For closest point, I have no idea without Daniel's *.arx...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3180
  • Marko Ribar, architect
Re: CLOSEST POINT to a 3D SOLID
« Reply #7 on: September 04, 2023, 11:16:27 AM »
Cancel my last message...It won't work with BBox.lsp - I've just checked... Only solution was my previous posts - Rhino and *.arx...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 720
Re: CLOSEST POINT to a 3D SOLID
« Reply #8 on: September 04, 2023, 11:21:28 AM »
Cancel my last message...It won't work with BBox.lsp - I've just checked... Only solution was my previous posts - Rhino and *.arx...
ok
don't worry
thank you

ribarm

  • Gator
  • Posts: 3180
  • Marko Ribar, architect
Re: CLOSEST POINT to a 3D SOLID
« Reply #9 on: September 04, 2023, 11:29:50 AM »
If you don't want to use *.arx and preview curves on 3DSOLID, then you could try command SURFEXTRACTCURVE and watch I suppose LWPOLYLINES/SPLINES on which I suppose you need to pick point... There are 2 directions, so you could create both directions and finally use OSNAP "int" - intersection... But to get 3DSOLID, you'll need Rhino, I don't know other way around this - non uniformly scaled 3DSOLID/SURFACE blocks... And AutoDesk wasn't interested in making this feature - it is long time issue, though it was related only for 3DSOLIDS/SURFACES - I mean EXPLODE-ing block that contains them...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ribarm

  • Gator
  • Posts: 3180
  • Marko Ribar, architect
Re: CLOSEST POINT to a 3D SOLID
« Reply #10 on: September 04, 2023, 12:18:31 PM »
I've found a way to extract BBox from a block, though not my code, should work - I've checked it... Now remains Dani's *.arx, or SURFEXTRACTCURVE...

code:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:BBox-ALE (/ ent llp urp )
  2.     (and
  3.         (setq ent (car (entsel "\nSelect block: ")))
  4.         (progn
  5.             (prompt "\nPick 3 points that define UCS of previously picked block...")
  6.             (command "_.UCS" "_3P")
  7.             (while (< 0 (getvar 'cmdactive))
  8.               (command "\\")
  9.             )
  10.             (gc:UcsBoundingBox ent 'llp 'urp)
  11.             (command "_.BOX" "_non" llp "_non" urp)
  12.             (command "_.UCS" "_P")          
  13.         )
  14.     )
  15.     (princ)
  16. )
  17.  
  18. ;; gc:UcsBoundingBox by Gile
  19. ;; Returns the UCS coordinates of the object bounding box about current UCS
  20. ;;
  21. ;; Arguments
  22. ;; obj: an entity (ENAME or VLA-OBJCET)
  23. ;; _OutputMinPtSym: a quoted symbol (output)
  24. ;; _OutputMaxPtSym: a quoted symbol (output)
  25.  
  26. (defun gc:UcsBoundingBox ( obj _OutputMinPtSym _OutputMaxPtSym )
  27.     (vl-load-com)
  28.     (and (= (type obj) 'ename)
  29.          (setq obj (vlax-ename->vla-object obj))
  30.     )
  31.     (vla-transformby obj (vlax-tmatrix (gc:TMatrixFromTo 1 0)))
  32.     (vla-getboundingbox obj _OutputMinPtSym _OutputMaxPtSym)
  33.     (vla-transformby obj (vlax-tmatrix (gc:TMatrixFromTo 0 1)))
  34.     (set _OutputMinPtSym (vlax-safearray->list (eval _OutputMinPtSym)))
  35.     (set _OutputMaxPtSym (vlax-safearray->list (eval _OutputMaxPtSym)))
  36. )
  37.  
  38. ;; gc:TMatrixFromTo by Gile
  39. ;; Returns the 4X4 transformation matrix from a coordinate system to an other one
  40. ;;
  41. ;; Arguments
  42. ;; from to: same arguments as for the 'trans' function
  43.  
  44. (defun gc:TMatrixFromTo ( from to )
  45.     (append
  46.         (mapcar
  47.             (function
  48.                 (lambda   ( v o )
  49.                     (append (trans v from to t) (list o))
  50.                 )
  51.             )
  52.            '(
  53.                 (1.0 0.0 0.0)
  54.                 (0.0 1.0 0.0)
  55.                 (0.0 0.0 1.0)
  56.             )
  57.             (trans '(0.0 0.0 0.0) to from)
  58.         )
  59.        '((0.0 0.0 0.0 1.0))
  60.     )
  61. )
  62.  

Thanks to the author Marc' Antonio and Gilles...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1447
  • Marco
Re: CLOSEST POINT to a 3D SOLID
« Reply #11 on: September 05, 2023, 09:16:51 AM »
I've found a way to extract BBox from a block, though not my code, should work - I've checked it... Now remains Dani's *.arx, or SURFEXTRACTCURVE...
...
Thanks to the author Marc' Antonio and Gilles...
Prego  :)   (thanks Gilles).

xdcad

  • Bull Frog
  • Posts: 424
Re: CLOSEST POINT to a 3D SOLID
« Reply #12 on: November 20, 2023, 10:11:13 PM »
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
[XDrx-Sub Forum]
https://www.theswamp.org/index.php?board=78.0
https://github.com/xdcad/XDrx-API
http://bbs.xdcad.net