Select surface labels

robert06
Collaborator
Collaborator

Select surface labels

robert06
Collaborator
Collaborator

How to select labels of one particular surface? Select similar filter can't be narrowed down to civil object detail, neither does not work Quick select by Surface name or style etc. Or am I missing something here?

 

0 Likes
Reply
Accepted solutions (1)
2,863 Views
12 Replies
Replies (12)

doni49
Mentor
Mentor

I don't know of a way to filter by surface.  But since labels are only shown for surfaces that are displayed, you could temporarily set the OTHER surfaces to a non-display surface style and the related labels will also turn off.   You will be left with the one remaing surface and its labels.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

tcorey
Mentor
Mentor

This LISP code makes a selection set for you. When you run another command and it asks to select objects, just give it P (previous).

 

(defun c:go ( / lbl srf srfnm All_lbls lbls clbl clblv clblsrf clblsrfnm len ctr)

  (vl-load-com)

  (setq lbl (vlax-ename->vla-object (car (entsel "\nSelect reference label: "))))
  ;(vlax-dump-object lbl t)
  (setq srf(vlax-get-property lbl 'Surface))
  ;(vlax-dump-object srf t)
  (setq srfnm (vlax-get-property srf 'Name))

  (setq All_lbls (ssget "x" (list (cons 0 "AECC_SURFACE_ELEVATION_LABEL")))
	len (sslength All_lbls)
	ctr 0)
  (setq lbls (ssadd))
  

  (while (< ctr len)
    (setq clbl (ssname All_lbls ctr))

    (setq clblv (vlax-ename->vla-object clbl)
	  clblsrf (vlax-get-property clblv 'Surface)
	  clblsrfnm (vlax-get-property clblsrf 'Name)
	  )
    (if (= clblsrfnm srfnm)
      (ssadd clbl lbls)
      )
    (setq ctr (1+ ctr))
    );end while

  (vl-cmdf "Select" lbls "")
  (princ)
    
    );end defun


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

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

doni49
Mentor
Mentor

Nice!



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

0 Likes

robert06
Collaborator
Collaborator

Hi, thank you!

Surface contour labels are groups and won't get selected with the lisp. Would it be possible that it worked also with surface label groups?

 

Robert

 

0 Likes

jmayo-EE
Mentor
Mentor

Kudos Tim. Very nice of  you to share the code I am sure everyone stuck using the NCS template or a variation of it will find the code useful.

 

On a side note I don't need the code. I can use the layer isolate command to do what the OP wants. 🙂

 

I am continually amazed at all the hoops the NCS template forces users to go through. Wasting time with new code to write, new commands to learn & new things to manage because the template is set up as it is with all styles hard coded to layers. This forces you to have layers and styles that you don't need to have, see, manage or waste time configuring layer filters and states for.

 

If a template is set up with Object layers configured in the drawing settings and all styles (object and label) are forced to layer zero then the layer isolate command on the surface labels will work as the OP requested and you will not get labels from other surfaces. No code needed. On top of this all layer commands work on all c3d objects (layoff, layfrx, layiso, laycur,etc). With this setup you have no need for layer filters or state since you can purge layers, no No need for the Object Isolate commands since the layer commands work...

John Mayo

EESignature

tcorey
Mentor
Mentor
Accepted solution

Try this:

 

(defun c:go ( / lbl srf srfnm All_lbls lbls clbl clblv clblsrf clblsrfnm len ctr lbltyp)

  (vl-load-com)

  (setq lbl (car (entsel "\nSelect reference label: ")))
  (setq lbltyp (cdr (assoc 0 (entget lbl))))
  (setq lbl (vlax-ename->vla-object lbl))
  
  ;(vlax-dump-object lbl t)
  (setq srf(vlax-get-property lbl 'Surface))
  ;(vlax-dump-object srf t)
  (setq srfnm (vlax-get-property srf 'Name))

  (setq All_lbls (ssget "x" (list (cons 0 lbltyp)))
	len (sslength All_lbls)
	ctr 0)
  (setq lbls (ssadd))
  

  (while (< ctr len)
    (setq clbl (ssname All_lbls ctr))

    (setq clblv (vlax-ename->vla-object clbl)
	  clblsrf (vlax-get-property clblv 'Surface)
	  clblsrfnm (vlax-get-property clblsrf 'Name)
	  )
    (if (= clblsrfnm srfnm)
      (ssadd clbl lbls)
      )
    (setq ctr (1+ ctr))
    );end while

  (vl-cmdf "Select" lbls "")
  (princ)
    
    );end defun



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

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut

robert06
Collaborator
Collaborator

Thank you, Tim!

I just added (sssetfirst nil lbls) to get them selected straight away.

 

Don's first proposal is a workaround, thanks for checking out the issue. Still, I would not like to hassle with setting & reverting the styles of surfaces, I  wonder why the native quick select option does not work with the labels, i believe it is intended to be possible as it is enabled in the quick select window.

 

John, thank you. I see now, you could set style layers to 0 and work with layers not styles. But, if it is necessary to change anything else in the style but properties handled by layer (color, lweight, linetype) - text height etc, you'll have to operate both, the layer and the style.

 

Also, I wish layer commands would work on civil styles' nested level if needed but that's another subject.

 

0 Likes

tcorey
Mentor
Mentor

John, what do you do in the case where he has spot elevation labels and contour labels for the same surface but he only wants to choose the spots?

 

 

 

 

 

 

 

 

 



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

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes

jmayo-EE
Mentor
Mentor
I would just put them on a different layer.

John Mayo

EESignature

0 Likes

Anonymous
Not applicable

Great code!

 

On 2017 often it does not work. Just ends with:

 

Select reference label: ; error: Automation Error. Unspecified error

 

What could be the problem?

 

Thanks a lot!

0 Likes

robert06
Collaborator
Collaborator
I've seen this, too. After reopening the drawing or maybe civil, it usually works again.
0 Likes

tcorey
Mentor
Mentor

Thanks an error we get when the code is written for older versions and we haven’t updated to the latest. I can take a look this afternoon or tomorrow. 



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

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes