no function definition : vlax-curve-getEndParam occurred

no function definition : vlax-curve-getEndParam occurred

hanywillim
Enthusiast Enthusiast
1,918 Views
9 Replies
Message 1 of 10

no function definition : vlax-curve-getEndParam occurred

hanywillim
Enthusiast
Enthusiast

I work with main lisp include this function:

 

; dellin1 deletes all Lines shorter than given units outside & inside blocks
 (defun dellin1 (mx / ss d i en mx)
;  (vl-load-com)
   (setq d 0) ; set # of deleted at 0
	 (if (setq ss (ssget "X" '((0 . "LINE,ARC,*POLYLINE,CIRCLE,SPLINE,ELLIPSE")))) ; select all LINES
    (progn 
      (repeat (setq i (sslength ss))
	     (setq en (ssname ss (setq i (1- i))))
	     (if (< (vlax-curve-getdistAtParam en (vlax-curve-getEndParam en)) mx) ; if shorter or equal than given unit
        (progn
         (setq d(1+ d)) ; add # of deleted
	       (entdel en) ; delete
        )
       )
      )
    ) ; progn
   ) ; if
   (vlax-for blk (vla-get-blocks(vla-get-activedocument (vlax-get-acad-object))) ; select all blocks
    (cond ( (and (= :vlax-false (vlax-get-property blk 'islayout)) ; not layout
                 ;(= :vlax-false (vlax-get-property blk 'isxref))   ; not xref
                 (= :vlax-false (vlax-get-property blk 'isdynamicblock)) ; not dynamic
            );end_and
            (vlax-for itm blk
              (if (and (or (= (strcase (substr (vlax-get itm 'objectname) 5)) "LINE")
               (= (strcase (substr (vlax-get itm 'objectname) 5)) "POLYLINE")
               (= (strcase (substr (vlax-get itm 'objectname) 5)) "CIRCLE")
               (= (strcase (substr (vlax-get itm 'objectname) 5)) "ARC")
               (= (strcase (substr (vlax-get itm 'objectname) 5)) "SPLINE"))
                       (< (vlax-curve-getdistatparam itm (vlax-curve-getendparam itm)) mx) ; if shorter or equal than given unit
                  );end_and
                (progn
                 (setq d(1+ d)) ; add # of deleted
                 (vla-delete itm) ; delete
                )
              );end_if
            );end_for
          )
    );end_cond
  );end_for
  (princ(strcat"\nDeleted Total of " (itoa d) " Lines."))(princ)
 ) ; defun dellin1

 

it work fine will most of all version of cad but in some versions (CAD 2019 i think) i got this error:
no function definition : vlax-curve-getEndParam occurred
so any suggestions please.
Thanks in advance

Accepted solutions (1)
1,919 Views
9 Replies
Replies (9)
Message 2 of 10

paullimapa
Mentor
Mentor

Maybe it’s because on that particular machine vl functions have not been loaded. Any reason for commenting out this line in the code with a semi colon instead of just executing it every time it runs which does no harm but guarantees the loading of vl functions ?

;  (vl-load-com)

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 10

_gile
Consultant
Consultant

Hi,

While using *POLYLINE in your selection filter, you could also get PolygonMesh and PolyFaceMesh entities.D



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 10

hanywillim
Enthusiast
Enthusiast

I removed the semi-colon for this line " (vl-load-com) " in all the lisp code, But still getting the same issue

 

Do you have any other suggestions 
Thanks in advance

0 Likes
Message 5 of 10

paullimapa
Mentor
Mentor

Sounds like you can easily replicate this error now. Perhaps you can provide more details as to when you get this. Does it only occur with a specific dwg?  If yes can you share this dwg?  Did it only occur in 2019 as you originally thought?  Does this error only occur when run with the main function or does it also occur when run by itself?  If only with main function, can you also share that?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 10

hanywillim
Enthusiast
Enthusiast

it is only happen with 2019 CAD version , with the mention code only 
And it happen with the all DWGs not a specific one .
Do you any other function or way  to do the same but can work with all cad version ?

0 Likes
Message 7 of 10

diagodose2009
Collaborator
Collaborator
Exists one site on web with AutoCad many version/s; The user\s cannot save and open Drawings. but they can test Vlide-Editor online and Lisp -program/s?
0 Likes
Message 8 of 10

paullimapa
Mentor
Mentor

Unfortunately I don’t have 2019 to test this. Perhaps others here do and can further assist you. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 9 of 10

Kent1Cooper
Consultant
Consultant

@hanywillim wrote:

.... Do you any other function or way  to do the same but can work with all cad version ?


[At the risk of insulting you:  Of course, after removing that semicolon, you Saved the file, and Loaded it again?]

 

But seriously....  If you comment out enough of it to avoid that particular function but not all (vl...) functions, do you get the same error but with a different function name?  That's what I would expect if the (vl-load-com) was not happening successfully.

 

If it doesn't have a problem with all (vl...) functions, but only that one, then for an open object, you could get its length with:
(vlax-curve-getDistAtPoint entityname (vlax-curve-getEndPoint entityname))

The problem is that for closed objects [Circles, closed Polyline/Ellipses/Splines], that returns 0, so in your case all such objects would be eliminated, no matter how long.

 

You could also do the testing with something like (getpropertyvalue) operations, or VLA properties, but the complication is that the name of the property varies by entity type -- for some it's "Length," but for a Circle it's "Circumference," for an Arc the VLA property is "Arclength" though the (getproperty...) one is "Length" as for some other kinds of things, an Ellipse doesn't have its length in either kind of property, etc.

 

I was about to suggest this:  Test for whether there is a point on it past your test length:

(vlax-curve-getPointAtDist entity mx)

That will return nil if the object is less than the test length [there will be no point on it at that distance], so it can be eliminated.  You might want to experiment with how sensitive it may be to Zoom level, and whether to put a small multiplier on that mx value, etc.

But I find that for a closed object like a Circle or full Ellipse [though not for a Polyline], it "finds" a point at a distance beyond the object's length -- it just keeps going farther around.

Kent Cooper, AIA
0 Likes
Message 10 of 10

eng_minamaged
Advocate
Advocate
Accepted solution

Code By @komondormrex 


 

(defun delete_less_max_length_lines (max_length / deleted_count)
	(setq deleted_count 0)
  	(vlax-map-collection (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
		'(lambda (block_definition)
		 	(if (and
			      	 (zerop (vlax-get block_definition 'isdynamicblock))
			      	 (zerop (vlax-get block_definition 'isxref))
		 	    )
			   	(vlax-map-collection block_definition
					'(lambda (object)
					 	(cond
							(
							 	(= "AcDbLine" (vla-get-objectname object))
							  		(if (> max_length (vla-get-length object))
										(progn
											(vla-delete object)
										  	(setq deleted_count (1+ deleted_count))
									  	)
								 	)
							)
							(
							 	t
							)
						)
					 )
			  	)
			 )
		)
	)
  	(princ (strcat "\nTotal of " (itoa deleted_count) " lines less than " (rtos max_length) " unit length deleted."))
  	(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acactiveviewport)
  	(princ)
)
0 Likes