Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to change a surface point elevation with visual lisp

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
tcorey
1014 Views, 2 Replies

How to change a surface point elevation with visual lisp

I am attempting to use lisp to change a TIN Surface point elevation using visual lisp.

 

I get the surface object with ename->vla-object

I retrieve the points safearray with vlax-get-property and then vlax-variant-value.

 

I now have a safearray from which I can extract each point's x y z using a counter.

 

I then thought I could use vlax-safearray-put-element to change the elevation. Debugging responds that the value has been 'put,' but I don't know how I need to figure out how to put it all back into the surface.

 

I notice that 'Points property of the surface object is read only. Does that mean I am spinning my wheels or is there a way to do this.

;This code evaluates surface points on Groundwater surface and changes them to equal OG surface if groundwater is higher.


(defun c:go ()

  (setq ogsrfv (vlax-ename->vla-object (car (entsel "\nSelect OG surface:")))
	gwsrfv (vlax-ename->vla-object (car (entsel "\nSelect GW surface: ")))
	)

 ; (vlax-dump-object ogsrfv t)
 ; (vlax-dump-object gwsrfv t)

  (setq gwpts (vlax-get-property gwsrfv 'Points))
  (setq gwptsvar (vlax-variant-value gwpts))
  (setq lb (vlax-safearray-get-l-bound gwptsvar 1))
  (setq ub (vlax-safearray-get-u-bound gwptsvar 1))
  (setq ctr lb)

  (while (<= ctr ub)
    (setq p1x (vlax-safearray-get-element gwptsvar ctr))
    (setq p1y (vlax-safearray-get-element gwptsvar (+ ctr 1)))
    (setq p1z (vlax-safearray-get-element gwptsvar (+ ctr 2)))


    ;Get OG elevation
      (setq OGz (vlax-invoke-method ogsrfv 'FindElevationAtXY p1x p1y))

;if gw elevation is higher than og, modify gw to match og
    (if (> p1z ogz)
	(vlax-safearray-put-element gwptsvar (atoi (rtos (+ ctr 2) 2 0)) OGz)
      );end if

    

	

    (setq ctr (+ ctr 3))
    
    );end while


   (princ)
  );end defun

 I am attaching a test drawing with a couple of very simple surfaces.

 

Please don't tell me to go learn .net. I know it's better and Autodesk doesn't want to support vlisp for Civil 3D, but vlisp is just so convenient for us non-programmers.

 

Thanks in advance for any sage advice...

 

Tim



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
2 REPLIES 2
Message 2 of 3
Jeff_M
in reply to: tcorey


@tcorey wrote:

I am attempting to use lisp to change a TIN Surface point elevation using visual lisp.

 

I am attaching a test drawing with a couple of very simple surfaces.

 

Please don't tell me to go learn .net. I know it's better and Autodesk doesn't want to support vlisp for Civil 3D, but vlisp is just so convenient for us non-programmers.

 

Thanks in advance for any sage advice...

 

Tim


Well...... I won't tell you, then, that the EditOperations are not available in the COM API but they are in the managed .NET API....

 

 

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 3
tcorey
in reply to: Jeff_M

I figured that was the case. Dang it.

 

Thanks, Jeff.

 

Tim



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report