Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Quick Select Labels using Label Style Name

23 REPLIES 23
Reply
Message 1 of 24
Anonymous
4314 Views, 23 Replies

Quick Select Labels using Label Style Name

I'm using Civil 3D 2013. I'd like to be able to select all of the spot grades that are using a specific style. I have tried using Quick Select to do this, but have had zero luck. Here are the parameters I've been using:

 

Apply to: Entire Drawing

Object type: Surface Elevation Label

Properties: Surface Spot Elevation Label Style

Operator: = Equals

Value: style_name

 

In the value box I paste in the name of the surface spot elevation label style. After clicking okay, it always says "0 item(s) selected". I've tried a few different style names (all of which are in use). I've searched the web and haven't really found any information about people using the quick select command for this purpose. Any thoughts? 

23 REPLIES 23
Message 2 of 24
tcorey
in reply to: Anonymous

That's very possible with a short LISP routine:

 

;select all labels of a particular style.

;copyright 2014, Timothy Corey
;Delta Engineering Systems
;Autodesk Authorized Value-Added Reseller
;Redding, CA

;permission is hereby granted to use this code for free.
;This code may not be sold or included in any for-sale software

;It is the repsonsibility of any person using this code
;to evaluate and test to be sure the code works for your needs.


(defun c:go ()

  ;get representative label and its lable style info
  (setq rep (car (entsel "\nSelect a representative label" )))
  (setq repv (vlax-ename->vla-object rep))
  (setq replblsty (vlax-get-property repv 'LabelStyle))
  (setq repname (vlax-get-property replblsty 'Name))

  (setq finalSS (ssadd))  ;create the container for filtered selection set
  

  (setq otyp (cdr (assoc 0 (entget rep))))   ;get object type
  (setq ls (ssget "x" (list (cons 0 otyp))) ;make selection set of all labels of type
  
	len (sslength ls)                    ;selection set length
	ctr 0)                               ;inititialize counter

 

  (while (< ctr len)
    (setq lbl (ssname ls ctr)) ;object in selection set at counter position
    (setq lblv (vlax-ename->vla-object lbl)) ;vlisp version of object
  (setq lblsty (vlax-get-property lblv 'LabelStyle)) ;labelstyle
  
  (setq styNam (vlax-get-property lblsty 'Name))   ;name of labelstyle

    (if (= styNam repname)   ;if item in list label style name equals representative object
      (ssadd lbl finalss)    ;add that object to the final selection set
      )
    (setq ctr (1+ ctr))       ;increment the counter
    );end while
  (vl-cmdf "Select" finalss "")     ;Use Select command to make a Previous selection set
  (prompt "\nUse Previous selection set to access labels...")
  (princ)
  );end defun

  

 Best regards,

 

Tim



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Tags (1)
Message 3 of 24
btmarvel
in reply to: tcorey

ive never loaded a lisp command before so i may have done this wrong, but when i type in "go", it tells me to select a representative label, so i select a pipe label from my pipe network, and hit enter, and then it just does nothing, its like the command was canceled. did i do something wrong?
Message 4 of 24
tcorey
in reply to: btmarvel

The OP said you wanted to create a selection set by label style name. This creates a selection set. To do something with it, start a command and when AutoCAD asks to Select Objects: type P for Previous.

 

If there is something specific you're trying to do with the selected labels, let me know what that is and I will modify the routine.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 5 of 24
btmarvel
in reply to: tcorey

aha! no that works, i just didnt understand that there was an extra step. thank you! i have a bunch of pipe labels that are on the same object layer but set to different styles, and i was trying to isolate the ones on a specific style and this works.
Message 6 of 24
AllenJessup
in reply to: btmarvel

Glad to hear Tim got you going with the lisp. The question does remain; Why doesn't QSelect work when by all appearances it should?

 

Allen

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 7 of 24
Anonymous
in reply to: tcorey

I actually posted the question not btmarvel, but it looks like you've posted something that has definitely helped him out. Thank you for posting the lsp. I'm still struggling to get it to work though. When I run the lsp, it asks me to "Select a representative label". As you posted (and as the code hints), I hit "p" enter. Since I selected a surface spot elevation label before I ran the lsp, I figured it would work. Unfortunately it tells me, "Invalid Selection", "Expects a point or Last".

 

To Allen's point, yes, why doesn't the Quick Select Command just work. It's interesting that when you use the tool to select by layer it provides a drop-down menu with a list of all of the layers. For the label styles it doesn't provide the same drop-down selection menu. Could it be that label styles have a computer recognizable name that differs from the name we see (and the quick select will only work with the computer recognizable name)?

Message 8 of 24
AllenJessup
in reply to: Anonymous

I think the QSelect routine is written to provide a list of properties it can extract from a selected object type. It's more likely it can extract a list from a basic AutoCAD object or a property that is basic to AutoCAD. It seems to have trouble with Civil 3D objects and properties.

 

Allen

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 9 of 24
AllenJessup
in reply to: Anonymous


@Anonymous wrote:

 Unfortunately it tells me, "Invalid Selection", "Expects a point or Last".


What command are you starting before you hit P? It has to be one that will accept a selection set of labels.

 

Allen

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 10 of 24
tcorey
in reply to: Anonymous

When the routine asks you to select a representative label, pick one on the screen.

 

The use of Previous selection set is after the lisp routine has finished and you are trying to select those filtered objects.

 

Let's say you want to Erase all spot elevation labels of style name TEST. Run the lisp routine, pick a label of that style name as a representative.

 

The routine is done. Now start the Erase command. When AutoCAD asks you to Select Objects: type P for Previous. This will select all those labels that were filtered into a selection set by the lisp routine.

 

Tim

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 11 of 24
Jeff_M
in reply to: tcorey

Change the 2 commented lines shown here with the uncommented one, then the PickFirst selection will be preselected (grips will be activated), then no P is needed when running the subsequent command.

;;(vl-cmdf "Select" finalss "") ;Use Select command to make a Previous selection set
;;(prompt "\nUse Previous selection set to access labels...")
(sssetfirst nil finalss)
Jeff_M, also a frequent Swamper
EESignature
Message 12 of 24
tcorey
in reply to: Jeff_M

Thanks, Jeff. I didn't know about sssetfirst.



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Gold Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 13 of 24
gle502
in reply to: tcorey

bitchen Camaro dude
Message 14 of 24
divanov
in reply to: tcorey

Is there a way to select labels by different property, e.g. label rotation angle?

 

Thanks

Message 15 of 24
AllenJessup
in reply to: divanov

I don't see an option for rotation. These are the options for Alignment Station Labels.

 

sq.png

Allen Jessup
CAD Manager - Designer
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

Message 16 of 24
divanov
in reply to: AllenJessup

Quick Select actually works when selecting by rotation angle. Thank you very much for making me try again.

 

 

Message 17 of 24
garrett_wynne
in reply to: Anonymous

Older post, but this LISP routine has helped out tremendously for my project.  Posting Kudos to the creator!

Message 18 of 24
mikeeddy15D95Z
in reply to: Anonymous

Great routine!

 

Any idea why it doesn't seem to work with General Line Segment labels?

 

Thanks for your time.

Message 19 of 24

Select a representative label; error: Automation Error. Unspecified error

 

Great routine except for line and curve labels. 

Message 20 of 24
adam
in reply to: SchwartzBwithU

To all who were wanting to use this for line and curve labels.

 

change

(setq replblsty (vlax-get-property repv 'LabelStyle))

and

(setq lblsty (vlax-get-property lblv 'LabelStyle)) ;labelstyle

to

(setq replblsty (vlax-get-property repv 'LineLabelStyle))

and

(setq lblsty (vlax-get-property lblv 'LineLabelStyle)) ;labelstyle

this needs to be a different lisp from the original post since the veriables are different. Maybe someone better than me can post a way to combine them. please note that a line also has an arc style listed and vise versa. this will grab all lines and arcs that have both styles the same.

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report