vl-vector-project-PointToEntity

I am having trouble implementing vl-vector-project-PointToEntity
Has anyone got it working ?

I have drawn a sphere at 0,0 radius 10m
I have drawn a line from 0,0 to 20,20

(defun c:vlv()
(setq p1 (getpoint "Pick Point")) ; point (20,20)
(setq vr (getpoint "pick VD Point")) ; viewdir (0,0)
(setq pient (entsel "Pick Surface/Solid")) ; Sphere
(setq ent (car pient))
(setq p2 (vl-vector-project-PointToEntity p1 vr ent))
)

also tried with surfaces - always return nil

Has anyone else got it working ( V22 & V23) ?

Comments

  • It's because you're specifying two points, rather than a point and a direction, which is what vl-vector-project-PointToEntity requires.

    To fix you need to find the direction vector from p1 to vr. Luckily BricsCAD LISP provides numerous vector functions to help with this type of task. Adding this step to your function gives the expected result.
    (defun c:vlv()
    	(setq p1 (getpoint "Pick Point")) ; Source
    	(setq vr (getpoint "pick VD Point")) ; Target
    	(setq dir (vle-vector-get p1 vr)) ; direction vector
    	(setq pient (entsel "Pick Surface/Solid")) ; Sphere
    	(setq ent (car pient))
    	(setq p2 (vl-vector-project-PointToEntity p1 dir ent))
    )
    

    Regards,
    Jason Bourhill
    BricsCAD V23 Ultimate
    CAD Concepts