Author Topic: GetParamAtPoint Problem  (Read 1196 times)

0 Members and 1 Guest are viewing this topic.

civil.eng

  • Newt
  • Posts: 66
GetParamAtPoint Problem
« on: June 13, 2021, 09:30:19 AM »
Hello everyone,
There is a problem with vlax-curve functions with 3Dpolyline, the attached file I wanted to use GetParamAtPoint function but it gives nil for some points while there is no problem with polyline and it occurs only with 3Dpolyline :

Code: [Select]
(defun c:ff ()
  (setq obj (vlax-ename->vla-object (car (entsel))))
  (setq pt (getpoint))
  (vlax-curve-getparamatpoint obj pt)
)

ribarm

  • Gator
  • Posts: 3262
  • Marko Ribar, architect
Re: GetParamAtPoint Problem
« Reply #1 on: June 13, 2021, 09:34:08 AM »
Code: [Select]
(defun c:ff ()
  (setq obj (vlax-ename->vla-object (car (entsel))))
  (setq pt (getpoint))
  (vlax-curve-getparamatpoint obj (vlax-curve-getclosestpointto obj (trans pt 1 0)))
)

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

:)

M.R. on Youtube

civil.eng

  • Newt
  • Posts: 66
Re: GetParamAtPoint Problem
« Reply #2 on: June 13, 2021, 09:40:40 AM »
Thanks, but your codes didn't work. Did you try it on the file?

ribarm

  • Gator
  • Posts: 3262
  • Marko Ribar, architect
Re: GetParamAtPoint Problem
« Reply #3 on: June 13, 2021, 10:01:41 AM »
Indeed, sometimes CAD just won't work as expected... I moved 3dpoly, point at middle of segment, tried several times and at the end it worked... Sometime you just have to nudge things a bit to make it work - that's CAD (it happens from time to time, for ex. intersectwith method doesn't work if entity is far away from origin 0,0,0 - this isn't such a case, you just have to do something on entity that behaves buggy...)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: GetParamAtPoint Problem
« Reply #4 on: June 13, 2021, 10:40:29 AM »
Also here returns nil
Work around it via retrieving the coordinates of that targeted polyline then sort them to nearest distance to pt with x and y only without Z.

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: GetParamAtPoint Problem
« Reply #5 on: June 13, 2021, 07:08:43 PM »
This is a known bug with the vlax-curve-* functions when the target entity is far from the origin - the below presents a possible workaround for you to consider:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / b e o p v x )
  2.     (if
  3.         (and
  4.             (setq e (car (entsel)))
  5.             (setq p (getpoint "\nSpecify point to obtain param: "))
  6.         )
  7.         (progn
  8.             (setq v (vlax-ename->vla-object e)
  9.                   b (vlax-curve-getstartpoint e)
  10.                   p (mapcar '- (trans p 1 0) b)
  11.                   b (vlax-3D-point b)
  12.                   o (vlax-3D-point 0 0)
  13.             )
  14.             (vla-move v b o)
  15.             (vla-move v o b)
  16.             (princ "\nParameter: ")
  17.             (prin1 x)
  18.         )
  19.     )
  20.     (princ)
  21. )