Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

vlax-invoke-method "FindElevationAtXY"

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Shinigami_black
1101 Views, 4 Replies

vlax-invoke-method "FindElevationAtXY"

Hi, I try to write a lisp to get elevation from TIN surface in AutoCAD Civil 3D. But coordinate can be not on surface. In this case I get an error and my lisp execution stops. Here are a function

 

(defun GetElevationAtXY (coordinate surfaceName / )
	(vlax-invoke-method surfaceName "FindElevationAtXY" (car coordinate) (cadr coordinate)))
)

 

If coordinate are not on surface I would like to return nil, and continue lisp execution. nil would be handled later in another function. Is it possible in lisp?

 

P.S.

error message I get are

Error. Automation Error. Triangle is deleted

 

4 REPLIES 4
Message 2 of 5

I found I can use vl-catch-all-apply for this, and added it to my function. But now I get error message like this

Error: bad argument type: symbolp nil

 This is my curent function

(defun GetElevationAtXY (coordinate surfaceName / z)
	(set z
	     (vl-catch-all-apply 'vlax-invoke-method (list surfaceName "FindElevationAtXY" (car coordinate) (cadr coordinate)))
	)
	(if (= (vl-catch-all-error-p z) T)
		(setq z nil)
		(setq z z)
	)
)

 This error is in line

(vl-catch-all-apply 'vlax-invoke-method (list surfaceName "FindElevationAtXY" (car coordinate) (cadr coordinate)))

 

Message 3 of 5
bhull1985
in reply to: Shinigami_black

http://www.lee-mac.com/errormessages.html

Here's the page where you can check the different error codes and what they mean, as well as tutorials on how to fix them.

Typically what follows a call to -invoke-method is a method, it appears as if that may not be the case in your line of code but perhaps im wrong

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Please use code tags and credit where credit is due. Accept as solution, if solved. Let's keep it trim people!
Message 4 of 5
Shinigami_black
in reply to: bhull1985

Here are samething wrong with list I make

To test  (vl-catch-all-apply 'vlax-invoke-method li) I have creaded li in AutoCAD command line

(setq li (list surfaceName "FindElevationAtXY" (car coordinate) (cadr coordinate)))

 And I got back this

(#<VLA-OBJECT IAeccTinSurface 000000002f769c80> "FindElevationAtXY" 419214 6144697)

 look at "FindElevationAtXY".

But if I do this in lisp

(defun GetElevationAtXY (coordinate surfaceName / z li)
	(setq li (list surfaceName "FindElevationAtXY" (car coordinate) (cadr coordinate)))
	(princ li)
	(set z
	    (vl-catch-all-apply 'vlax-invoke-method li)
	)
	(if (= (vl-catch-all-error-p z) T)
		(setq z nil)
		(setq z z)
	)
)

 I get this printed

(#<VLA-OBJECT IAeccTinSurface 000000002f769c80> FindElevationAtXY 419143.0 6.14477e+006)

 "FindElevationAtXY" became FindElevationAtXY. So probably it is treated as variable and not as string. But here are no variable FindElevationAtXY so it is equal to nil.

But how to fix it?

Message 5 of 5

It was my mistake.
was not (setq z
but was (set z

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost