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: 

change point label style in autocad civil3D 2013 using autolisp

4 REPLIES 4
Reply
Message 1 of 5
amyyoyo1
929 Views, 4 Replies

change point label style in autocad civil3D 2013 using autolisp

Hi, I not sure if this something easy to do. I did some search and got some code from 2009 post which not really working for me.since I am not a pofr for autocad civil3D and just staring to learn how programing with autolisp, I am having trouble to debug the code myself.I

(defun xp()
(setq sset1 (ssget "X" '((0 . "AECC_PARCEL_SEGMENT"))))
  (COMMAND "EXPLODE" SSET1 "")
  if (= (setq ss (ssget "X" '((0 . "AECC_COGO_POINT")))) nil)
 
    (setq ss (ssget "x" '((0 . "AECC_COGO_POINT"))))
  )
;FILTERS UNCLOSED POLYLINES
(defun c:changestyle()
 (setq xlabel (vlax-ename->vla-object (car (entsel))))
 (setq prod (vlax-product-key))
 (setq prodStr (strcat "AeccXUiLand.AeccApplication"
 (cond ((vl-string-search "\\R17.0\\" prod)
 ".4.0"
 )
 ;;2007
 ((vl-string-search "\\R17.1\\" prod)
 ".5.0"
 )
 ;;2008
 ((vl-string-search "\\R17.2\\" prod)
 ".6.0"
 )
 ;;2009
 ((vl-string-search "\\R18.0\\" prod)
 ".7.0"
 )
 ;;2010
 (t "")
 )
 )
 )
 (and (setq *acad* (vlax-get-acad-object))
 (setq C3D (vla-getinterfaceobject *acad* prodStr))
 (setq C3Ddoc (vla-get-activedocument C3D))
 )
 (setq Point_label_style (vlax-get c3ddoc 'PointLabelStyles))
 (vlax-for x Point_label_style
 (if (eq (vlax-get x 'name) "_WA Topo Data w-Elev")
 (setq Point_label x)
 )
 )
 (if (vlax-get xlabel 'Style) ;;;make sure the point has a style, else it will error
 (vlax-put xlabel 'labelstyle Point_label)
 )
 (vlax-release-object c3ddoc)
 (vlax-release-object c3d)
 (princ)
 )
 

 

hope some one can help me out a bit here. please and thanks

4 REPLIES 4
Message 2 of 5
Jeff_M
in reply to: amyyoyo1

Here is the code updated to work through C3D2014. Note that the style to be used needs to be changed to suit your styles.

(defun c:changestyle (/ *acad* c3d c3ddoc point_label point_label_style prod prodstr xlabel)
  (setq xlabel (vlax-ename->vla-object (car (entsel))))
  (setq prod (vlax-product-key))
  (setq	prodStr	(strcat	"AeccXUiLand.AeccApplication"
			(cond ((vl-string-search "\\R17.0\\" prod)
			       ".4.0"
			      )
			      ;;2007
			      ((vl-string-search "\\R17.1\\" prod)
			       ".5.0"
			      )
			      ;;2008
			      ((vl-string-search "\\R17.2\\" prod)
			       ".6.0"
			      )
			      ;;2009
			      ((vl-string-search "\\R18.0\\" prod)
			       ".7.0"
			      )
			      ;;2010
			      ((vl-string-search "\\R18.1\\" prod)
			       ".8.0"
			      )
			      ;;2011
			      ((vl-string-search "\\R18.2\\" prod)
			       ".9.0"
			      )
			      ;;2012
			      ((vl-string-search "\\R19.0\\" prod)
			       ".10.0"
			      )
			      ;;2013
			      ((vl-string-search "\\R19.1\\" prod)
			       ".10.3"
			      )
			      ;;2014
			      (t "")
			)
		)
  )
  (and (setq *acad* (vlax-get-acad-object))
       (setq C3D (vla-getinterfaceobject *acad* prodStr))
       (setq C3Ddoc (vla-get-activedocument C3D))
  )
  (setq Point_label_style (vlax-get c3ddoc 'PointLabelStyles))
  (vlax-for x Point_label_style
    (if	(eq (vlax-get x 'name) "Standard")
      ;;<<<CHange to the style name you want to use!
      (setq Point_label x)
    )
  )
  (if (vlax-get xlabel 'Style)
    (vlax-put xlabel 'labelstyle Point_label)
  )
  (vlax-release-object c3ddoc)
  (vlax-release-object c3d)
  (princ)
)

 

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

thank you so much it work well!

Message 4 of 5
amyyoyo1
in reply to: amyyoyo1

sorry to ask this. I not sure if it do able though autolisp, it there a way to change the label visibility ?

 

Message 5 of 5
Jeff_M
in reply to: amyyoyo1

Yes. Here's some example code to set the first text component in the PointLabelStyle "Elevation only" to not be visible:

 

(setq Point_label_styles (vlax-get c3ddoc 'PointLabelStyles))
(setq lblstyl1 (vlax-get-property Point_label_styles 'item "Elevation Only"))
(setq txtcomps (vlax-get lblstyl1 'textcomponents))
(setq txtcomp1 (vlax-get-property txtcomps 'item 0))
(setq visible (vlax-get-property txtcomp1 'visibility))
(vlax-put-property visible 'value :vlax-false)

 

Jeff_M, also a frequent Swamper
EESignature

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report