Jump to content

How to get label names existing in a drawing using visuallisp.


Recommended Posts

Posted

How to get label names existing in a drawing using visuallisp.

Label.jpg

Posted

Thanks Commandobill.

I modified some code from this forum.

Maybe someone will use it.

The program works only in Civil 3D 2014, but it's not a problem.

(prompt "\ncglab")
(vl-load-com)
(defun c:cglab (/ C3Ddoc ptlblstyles styl lst)
 (setq C3Ddoc (vla-get-activedocument (vla-getinterfaceobject (vlax-get-acad-object) "AeccXUiLand.AeccApplication.10.3")))
 (setq ptlblstyles (vlax-get C3Ddoc 'pointlabelstyles))
 (vlax-for styl ptlblstyles
   (print (vlax-get styl 'name))
   (setq lst (cons (vlax-get styl 'name) lst))
   )
 (print lst)
 (princ)
 )

Posted

Here is one way to get the versions. What are you trying to do ? It gets complicated playing with the styles, some things you look for are not located where you think they should be.

 

;vercheck.lsp  version check for *aecc objects

(defun ah:vercheck ( / vrsn appstr)
(vl-load-com)
(if ((lambda (vrsn)
       (cond
        ((vl-string-search "R17.2" vrsn) (setq appstr "6.0")) ;09
        ((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;10
        ((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;11
        ((vl-string-search "R18.2" vrsn) (setq appstr "9.0")) ;12 ?
        ((vl-string-search "R19.0" vrsn) (setq appstr "10.0")) ;13 
        ((vl-string-search "R19.1" vrsn)(setq appstr "10.3"));;2014
        ((vl-string-search "R20.0" vrsn)(setq appstr "10.4"));;2015
        ((vl-string-search "R20.1" vrsn)(setq appstr "10.5"));;2016     
        ((vl-string-search "R21.0" vrsn)(setq appstr "11.0"));;2017  
((vl-string-search "R22.0" vrsn)(setq appstr "12.0"));;2018   
((alert "This version of C3D not supported!"))
       )
      )
      (vlax-product-key)
     )                         ; end if condition progn is true
     (progn
       (cond (*AeccDoc*)
         ((setq *AeccDoc*
           (vlax-get
             (cond (*AeccApp*)
               ((setq *AeccApp*
                 (vla-getinterfaceobject
                    (cond (*Acad*)
                    ((setq *Acad* (vlax-get-acad-object)))
                    )
                    (strcat "AeccXUiLand.AeccApplication." appstr)
                 )
                )
               )
             )
             'ActiveDocument
           )
          )
         )
       ) ; end main cond
     ) ; end progn
) ; end if vsrn
)

 

You may be interested in this.

CH Points style.zip

Chcontourstoolbar.zip

Posted
Here is one way to get the versions. What are you trying to do ? It gets complicated playing with the styles, some things you look for are not located where you think they should be.

 

;vercheck.lsp  version check for *aecc objects

(defun ah:vercheck ( / vrsn appstr)
(vl-load-com)
(if ((lambda (vrsn)
       (cond
        ((vl-string-search "R17.2" vrsn) (setq appstr "6.0")) ;09
        ((vl-string-search "R18.0" vrsn) (setq appstr "7.0")) ;10
        ((vl-string-search "R18.1" vrsn) (setq appstr "8.0")) ;11
        ((vl-string-search "R18.2" vrsn) (setq appstr "9.0")) ;12 ?
        ((vl-string-search "R19.0" vrsn) (setq appstr "10.0")) ;13 
        ((vl-string-search "R19.1" vrsn)(setq appstr "10.3"));;2014
        ((vl-string-search "R20.0" vrsn)(setq appstr "10.4"));;2015
        ((vl-string-search "R20.1" vrsn)(setq appstr "10.5"));;2016     
        ((vl-string-search "R21.0" vrsn)(setq appstr "11.0"));;2017  
((vl-string-search "R22.0" vrsn)(setq appstr "12.0"));;2018   
((alert "This version of C3D not supported!"))
       )
      )
      (vlax-product-key)
     )                         ; end if condition progn is true
     (progn
       (cond (*AeccDoc*)
         ((setq *AeccDoc*
           (vlax-get
             (cond (*AeccApp*)
               ((setq *AeccApp*
                 (vla-getinterfaceobject
                    (cond (*Acad*)
                    ((setq *Acad* (vlax-get-acad-object)))
                    )
                    (strcat "AeccXUiLand.AeccApplication." appstr)
                 )
                )
               )
             )
             'ActiveDocument
           )
          )
         )
       ) ; end main cond
     ) ; end progn
) ; end if vsrn
)

 

You may be interested in this.

Here is another way to get the versions ( Jeff M )

Posted

Thank you for your help.

BIGAL thanks for the programs.

I need one more information. How to set the label to none?

If none label is set.

(vlax-get-property (vlax-ename->vla-object (car (entsel))) 'LabelStyle)

Returns: nil

If any label is set.

(vlax-get (vlax-get-property (vlax-ename->vla-object (car (entsel))) 'LabelStyle) 'Name)

Returns for example: "Point Number Only"

 

Setting the label on nil returns an error.

(vlax-put-property (vlax-ename->vla-object (car (entsel))) 'LabelStyle nil)

How to set the label to none?

Posted

Have a look at this. You change the 'Pointgroups style not the entity. This is what I was getting at look elsewhere to change some stuff. The entity tells what style is in use.

CH Points style.zip

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...