samifox 发表于 2022-7-6 06:41:15

debug help :bad argument type:

Hi
 
this code is trying to distribute points along a polyline.
 

(Defun c:demo (/ pline int in pt ppt mspace thepoint) (if (and (setq pline (car (entsel "\nSelect Polyline:")))      (eq (cdr (assoc 0 (entget pline))) "LWPOLYLINE")      (setq int (getdist "\nEnter Interval:"))      (setq in int)   )   (while (Setq pt (vlax-curve-getPointAtDist pline int))   (setq ppt (vlax-curve-getparamatpoint pline pt))   (vlax-invoke   (vlax-ename->vla-object pline)   (setq mspace (vla-get-modelspace            (vla-get-activedocument            (vlax-get-acad-object)            )            )   )   (princ ppt)   (setq thepoint (vla-AddPoint mspace (vlax-3d-point pt)))   (1+ (fix ppt))   (list (car pt) (Cadr pt))   )   (setq int (+ int in))   ) ))why its yell an error?
 
Thanks
Shay

MSasu 发表于 2022-7-6 07:01:40

I believe that you don't need that VLAX-INVOKE(-METHOD); also is better to don't create the space object at each parse:

(Defun c:demo (/ pline int in pt ppt mspace thepoint) (if (and (setq pline (car (entsel "\nSelect Polyline:")))      (eq (cdr (assoc 0 (entget pline))) "LWPOLYLINE")      (setq int (getdist "\nEnter Interval:"))      (setq in int)   )   (progn    (setq mspace (vla-get-modelspace            (vla-get-activedocument            (vlax-get-acad-object)            )            )    (while (Setq pt (vlax-curve-getPointAtDist pline int))   (setq ppt (vlax-curve-getparamatpoint pline pt))      ;(vlax-invoke    (vlax-ename->vla-object pline)   )   (princ ppt)   (setq thepoint (vla-AddPoint mspace (vlax-3d-point pt)))   (1+ (fix ppt))   (list (car pt) (Cadr pt))            (setq int (+ int in))   )) ))

pBe 发表于 2022-7-6 07:21:26

 
The use of Vlax-invoke doesnt require you to "convert" the point coordinate to a variant 3D point. . so it wouldn't hurt to use it at all.
Also, on what your wanting to do, no need for vlax-curve-getparamatpoint
 

(Defun c:demo (/ pline int in pt ppt mspace thepoint) (if (and (setq pline (car (entsel "\nSelect Polyline:")))   (eq (cdr (assoc 0 (entget pline))) "LWPOLYLINE")   (setq int (getdist "\nEnter Interval:"))   (setq in int)   )   (progn   (setq mspace (vla-get-modelspace             (vla-get-activedocument             (vlax-get-acad-object)             )           )   )   (while (Setq pt (vlax-curve-getPointAtDist pline int))(setq thepoint (vlax-invoke mspace 'AddPoint pt))(setq int (+ int in))   )   ) )(princ))
 
But then again. why not use _measure command.

samifox 发表于 2022-7-6 07:31:33

 
i thought that using command line is slower than programming it, am i mistaken? how can i store all the coordinates of the distributed points than?
 
Thanks
Shay

gS7 发表于 2022-7-6 07:50:38

 

(Setq lst nil)(setq lst (cons pt lst))
页: [1]
查看完整版本: debug help :bad argument type: