TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: cousinchad on September 14, 2022, 07:49:29 AM

Title: LISP COGO Point Label Style
Post by: cousinchad on September 14, 2022, 07:49:29 AM
I'm looking for a LISP routine that would allow me to set the Point Label Style of a COGO point by simply clicking on it. I have lots of topo shots close together so I would like to be able to set the Point Label Style to the style I've created "V-NONE" that has no text. Any help would be appreciated, thank you!
Title: Re: LISP COGO Point Label Style
Post by: CodeDing on September 16, 2022, 02:27:36 PM
cousinchad,

This code should do the trick for you. I added the Point Label Style (PLS) command, at bottom, so you could test it out (feel free to obviously change it however necessary for your workflow. The alert boxes are mainly there for your testing to see it working). Please note, the other 2 included functions are required to run to create my global *C3D* and *docC3D* variables. They are the absolute baseline necessity when working with Civil 3D objects.

Code - Auto/Visual Lisp: [Select]
  1. ;; Returns the AeccXUiLandLib Interface object (as vla object)
  2. ;; (the primary object that allows us to edit 'Civil' related items [alignment, surface, points, etc.])
  3. ;; Also sets as global var
  4. (defun C3D-GetC3D ( / C3D)
  5.   (setq C3D (strcat "HKEY_LOCAL_MACHINE\\"
  6.                     (if vlax-user-product-key
  7.                       (vlax-user-product-key)
  8.                       (vlax-product-key)
  9.                     );if
  10.             );strcat
  11.         C3D (vl-registry-read C3D "Release")
  12.         C3D (substr
  13.               C3D
  14.               1
  15.               (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1))
  16.             );substr
  17.         *C3D* (vla-getinterfaceobject
  18.                 (vlax-get-acad-object)
  19.                 (strcat "AeccXUiLand.AeccApplication." C3D)
  20.               );vla-getinterfaceobject
  21.   );setq
  22. );defun
  23.  
  24. ;; Returns the active C3D document (as vla object)
  25. ;; Also sets as global var
  26. (defun C3D-GetC3DActiveDocument ( / )
  27.   (setq *docC3D* (vla-get-activedocument *C3D*))
  28. );defun
  29.  
  30. (defun c:PLS ( / myStyleName pointLabelStyles myStyle e)
  31.   (C3D-GetC3D)
  32.   (C3D-GetC3DActiveDocument)
  33.   (setq myStyleName "V-NONE") ;<-- update your Point Label Style name here
  34.   (setq pointLabelStyles (vlax-get-property *docC3D* 'PointLabelStyles))
  35.   (setq myStyle (vl-catch-all-apply 'vlax-get-property (list pointLabelStyles 'Item myStyleName)))
  36.   (if (and (not (vl-catch-all-error-p myStyle))
  37.            (setq e (car (entsel (strcat "\nSelect Cogo Point to apply the \"" myStyleName "\" Point Label Style: "))))
  38.            (eq "AECC_COGO_POINT" (cdr (assoc 0 (entget e))))
  39.            (setq e (vlax-ename->vla-object e)))
  40.     (progn
  41.       (vlax-put-property e 'LabelStyle myStyle)
  42.       (alert (strcat "SUCCESS; The \"" myStyleName "\" Point Label Style has been applied."))
  43.     );progn
  44.   ;else
  45.     (alert (strcat "FAILURE; The Point Label Style \"" myStyleName "\" does not exist OR Cogo Point Entity not selected."))
  46.   )
  47.   (princ)
  48. )
  49.  

Best,
~DD
Title: Re: LISP COGO Point Label Style
Post by: BIGAL on September 16, 2022, 08:00:35 PM
Also

https://www.cadtutor.net/forum/topic/76018-lisp-routine-to-set-cogo-point-label-style/#comment-600581
Title: Re: LISP COGO Point Label Style
Post by: BlackBox on September 19, 2022, 12:52:51 PM
https://forums.autodesk.com/t5/civil-3d-customization/lisp-toggle-cogo-point-label-visibility/m-p/11420877/highlight/true#M22179