TheSwamp
CAD Forums => Vertically Challenged => Topic started by: Rod 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.
-
That pretty much sums it up.
-
OK. Thanks Jeff
-
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.
-
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.
-
Lisp is good ... of course you could also build one in C# relatively easily.
-
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
(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 ")
-
Nice Job Rod.... I can follow it! lol.