Author Topic: LISP COGO Point Label Style  (Read 1025 times)

0 Members and 1 Guest are viewing this topic.

cousinchad

  • Mosquito
  • Posts: 1
LISP COGO Point Label Style
« 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!

CodeDing

  • Newt
  • Posts: 50
Re: LISP COGO Point Label Style
« Reply #1 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
« Last Edit: September 17, 2022, 08:16:17 AM by CodeDing »
~DD
Senior CAD Tech & AI Specialist
Need AutoLisp help?
Try my custom GPT 'AutoLISP Ace'

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
A man who never made a mistake never made anything

BlackBox

  • King Gator
  • Posts: 3770
"How we think determines what we do, and what we do determines what we get."