Author Topic: Tool Palette Lisp for Setting Coordinates in Civil 3D  (Read 210 times)

0 Members and 1 Guest are viewing this topic.

schueler8

  • Mosquito
  • Posts: 1
Tool Palette Lisp for Setting Coordinates in Civil 3D
« on: November 19, 2020, 02:08:34 PM »
Not even sure if this is something that can be done, but what im looking for is a lsp routine that i can set in a tool palette that will set the coordinate system in your drawing settings. we use 3 or 4 different coordinate systems and i would like the user to just click on a tool in the palette that will set this for them, without them having to do it manually.
Thanks in advance.

MSTG007

  • Water Moccasin
  • Posts: 2454
  • I can't remeber what I already asked! I need help!
Re: Tool Palette Lisp for Setting Coordinates in Civil 3D
« Reply #1 on: November 20, 2020, 02:26:28 PM »
This is a sample of what I use to get this to work. I hope this helps.

Code: [Select]
(vl-load-com)
(defun _GetAeccDocument ()
  (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
C3D (vl-registry-read C3D "Release")
C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1)))
C3D (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AeccXUiLand.AeccApplication." C3D)))
  (vlax-get-property C3D 'ActiveDocument)
  )
(defun getPositionMarkerCoords (  / ad s ds ts rp le ln p)
 (setq ad (_GetAeccDocument))
 (setq s (vlax-get-property ad 'Settings))
 (setq ds (vlax-get-property s 'DrawingSettings))
 (setq ts (vlax-get-property ds 'TransformationSettings))
 (setq rp (vlax-get-property ts 'ReferencePoint))
 (setq le (vlax-get-property rp 'LocalEasting))
 (setq ln (vlax-get-property rp 'LocalNorthing))
 (setq p (list le ln))
 )

(defun c:zoomtogeolocation ()
 (setq p (getPositionMarkerCoords))
 (command "_.CIRCLE" (getPositionMarkerCoords) "1500000" "ZOOM" "EXTENTS" "_.ERASE" (ssget "x" '((0 . "CIRCLE"))) "" "_GEOMAP" "HYBRID")
 (princ)
 )
Civil3D 2020

Jeff_M

  • King Gator
  • Posts: 3982
  • C3D user & customizer
Re: Tool Palette Lisp for Setting Coordinates in Civil 3D
« Reply #2 on: November 20, 2020, 02:30:31 PM »
Here's a small lisp that can do this.
Code - Auto/Visual Lisp: [Select]
  1. (defun setcoordsys (cs / C3D C3DDOC SETTINGS)
  2.   (setq C3D (strcat "HKEY_LOCAL_MACHINE\\"
  3.                     (if vlax-user-product-key
  4.                       (vlax-user-product-key)
  5.                       (vlax-product-key)
  6.                     )
  7.             )
  8.         C3D (vl-registry-read C3D "Release")
  9.         C3D (substr C3D
  10.                     1
  11.                     (vl-string-search
  12.                       "."
  13.                       C3D
  14.                       (+ (vl-string-search "." C3D) 1)
  15.                     )
  16.             )
  17.         C3D (vla-getinterfaceobject
  18.               (vlax-get-acad-object)
  19.               (strcat "AeccXUiLand.AeccApplication." C3D)
  20.             )
  21.   )
  22.   (setq C3Ddoc (vla-get-activedocument C3D))
  23.   (setq settings
  24.          (vlax-get
  25.            (vlax-get
  26.              (vlax-get (vlax-get c3ddoc 'settings) 'drawingsettings)
  27.              'unitzonesettings
  28.            )
  29.            'coordinatesystem
  30.          )
  31.   )
  32.   (vlax-put settings 'cscode cs)
  33.   (princ)
  34. )
  35.  
Make sure t gets loaded at drawing startup. Add as many calls to it on a palette as needed, for instance this will set the Coordinate System to "California Zone II, US FT (or use HARN/CA.CA-IIF)": (setcoordsys "CAHP-IIF")

MSTG007

  • Water Moccasin
  • Posts: 2454
  • I can't remeber what I already asked! I need help!
Re: Tool Palette Lisp for Setting Coordinates in Civil 3D
« Reply #3 on: November 23, 2020, 08:07:28 AM »
Thanks for sharing Jeff!
Civil3D 2020