Author Topic: Surface labels on layer depending on label type  (Read 8325 times)

0 Members and 1 Guest are viewing this topic.

Rod

  • Newt
  • Posts: 185
Surface labels on layer depending on label type
« on: August 06, 2021, 02:10:44 AM »
Does anyone have anything that will assist in putting Civil surface labels on different layers depending on what label type it is.
The in-built drawings settings will put contour, elevation and slope lables all on the same layer.

If I roll my own the options are to
  • Write new functions that will take the place of the label commands; or
  • Write reactor/s that will place labels on the correct layer once a command is finished; or
  • Write a command that once run will move all labels to the correct layers

I am missing anything?

Cheers, Rod.
"All models are wrong, some models are useful" - George Box

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Surface labels on layer depending on label type
« Reply #1 on: August 07, 2021, 08:10:57 PM »
That pretty much sums it up.

Rod

  • Newt
  • Posts: 185
Re: Surface labels on layer depending on label type
« Reply #2 on: August 09, 2021, 12:33:25 AM »
OK. Thanks Jeff
"All models are wrong, some models are useful" - George Box

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Surface labels on layer depending on label type
« Reply #3 on: August 17, 2021, 12:19:50 AM »
I have a VBA reactor that runs whenever a block is inserted into a drawing. If the block name has never been inserted previously, it prompts the user for the layer to force that block to be on. But like I said, it is VBA and I'm not sure if VBA is supported in newer versions. I am still using my perpetual license from 2007 ... because well .. it works for everything I need.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Rod

  • Newt
  • Posts: 185
Re: Surface labels on layer depending on label type
« Reply #4 on: August 17, 2021, 12:25:17 AM »
Thanks Keith, but I'll stick to lisp.

Once I get around to it I'll start with "Write a command that once run will move all labels to the correct layers" should be fairly straight forward.

Cheers, Rod.
"All models are wrong, some models are useful" - George Box

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Surface labels on layer depending on label type
« Reply #5 on: August 17, 2021, 09:44:05 PM »
Lisp is good ... of course you could also build one in C# relatively easily.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Rod

  • Newt
  • Posts: 185
Re: Surface labels on layer depending on label type
« Reply #6 on: August 18, 2021, 01:45:41 AM »
Here is my progress.

SSLL to set surface label layer
Puts elevation labels on "Surf-" <surface name> "-Labels-Elev"
Puts slope labels on "Surf-" <surface name> "-Labels-Slope"
Puts contour labels on "Surf-" <surface name> " (which for me is the same as the surface)

If there isn't a layer one will be made with default properties

Thanks, Guys

Code: [Select]
(defun C:setSurfaceLabelLayer (/ ss1 i len)
  (setq ss1 (ssget "X"
   '((0 . "AECC_SURFACE_SLOPE_LABEL,AECC_SURFACE_ELEVATION_LABEL,AECC_SURFACE_CONTOUR_LABEL_GROUP"))
    ) ;_ end of ssget
  ) ;_ end of setq
  (setq i 0)
  (if (and ss1 (> (setq len (sslength ss1)) 0))
    (while (< i len)
      (setSurfaceLabelLayer (ssname ss1 i))
      (setq i (1+ i))
    ) ;_ end of while
  ) ;_ end of if
  (princ)
) ;_ end of defun

(defun c:ssll ()
  (C:setSurfaceLabelLayer)
) ;_ end of defun

(defun setSurfaceLabelLayer (en / eList enType obj surf surfName)
  (setq elist (entget en))
  (setq enType (cdr (assoc 0 elist)))
  (setq obj  (vlax-ename->vla-object en)
surf (getProperty obj 'Surface)
  ) ;_ end of setq
  (if surf
    (progn
      (setq surfName
     (vlax-get-property surf 'Name)
      ) ;_ end of setq
    ) ;_ end of progn
  ) ;_ end of if
  (cond
    ((= enType "AECC_SURFACE_SLOPE_LABEL") (setq newlayer (strcat "Surf-" surfName "-Labels-Slope")))
    ((= enType "AECC_SURFACE_ELEVATION_LABEL") (setq newlayer (strcat "Surf-" surfName "-Labels-Elev")))
    (T (setq newlayer (strcat "Surf-" surfName)))
  ) ;_ end of cond
  (makeLayer newLayer)
  (setProperty obj 'Layer newlayer)
) ;_ end of defun

(defun getProperty (object prop / result)
  (vl-catch-all-apply
    (function
      (lambda ()
(setq result
       (vlax-get-property object prop)
) ;_ end of setq
      ) ;_ end of lambda
    ) ;_ end of function
  ) ;_ end of vl-catch-all-apply
  result
) ;_ end of defun

(defun makeLayer (name)
  (if (null (tblsearch "LAYER" name))
    (entmake
      (list
'(000 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(070 . 0)
(cons 002 name)
      ) ;_ end of list
    ) ;_ end of entmake
  ) ;_ end of if
) ;_ end of defun

(defun setProperty (oname property value)
  ;; Eg. (setproperty (Oname 'Radius 2.0))
  (if (vlax-property-available-p oname property T)
    (vlax-put-property oname property value)
  ) ;_ end of if
) ;_ end of defun

(princ "\nUse ssll to set surface label layer ")

"All models are wrong, some models are useful" - George Box

MSTG007

  • Gator
  • Posts: 2598
  • I can't remeber what I already asked! I need help!
Re: Surface labels on layer depending on label type
« Reply #7 on: August 18, 2021, 07:26:51 AM »
Nice Job Rod.... I can follow it! lol.
Civil3D 2020