Creating COGO Point and updating its Elevation

By Partha Sarkar

This AutoLISP code snippet demonstrates how to create a COGO Point in AutoCAD Civil 3D and update it's elevation property.

(defun c:CreateCOGO ()

  (vl-load-com)

  ;; Change ProgID per Traget Civil 3D version

  ;; This code sample is meant for Civil 3D 2013

  (setq aeccApp (vla-getinterfaceobject

          (vlax-get-acad-object)

          "AeccXUiLand.AeccApplication.10.0"

        )

  )

  (setq aeccDoc (vlax-get-property aeccApp "ActiveDocument"))

  (setq aeccDb (vlax-get-property aeccDoc "Database"))

  (setq oPoints (vlax-get-property aeccDoc "Points"))

  (setq pt1 (vlax-3d-point '(10.0 10.0 0.0)))

  (setq oPoint1 (vlax-invoke-method oPoints "Add" pt1))

  (setq elevn1 (vlax-get-property oPoint1 "Elevation"))

  (setq str1 "Initial Elevation = ")

  (prompt str1)

  (princ elevn1)

  ;; Set the COGO Point Elevation to a new Value

  (vlax-put-property oPoint1 "Elevation" 101.0)

  (setq elevn2 (vlax-get-property oPoint1 "Elevation"))

  (setq str2 "Elevation after change= ")

  (print str2)

  (princ elevn2)

)

BTW – COGO Point and its associated functionalities are exposed in .NET API in Civil 3D 2013 release and you might find my colleague Isaac's blog post 21WOJP – Week 5: COGO Point Basics very useful


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading