Code Red > AutoLISP (Vanilla / Visual)

LM:SentenceCase Use in routine

(1/5) > >>

jlogan02:
I want to set the layer filter name to Sentence Case using Lee Mac's LM:SentenceCase


--- Code - Auto/Visual Lisp: ---;; Sentence Case - Lee Mac;; Returns the supplied string converted to Sentence Case (defun LM:SentenceCase ( s / f )    (vl-list->string        (mapcar            (function                (lambda ( a b c )                    (if (or f (= 46 a)) (progn (setq f (= 32 b)) b) c)                )            )            (cons 46 (vl-string->list s))            (vl-string->list (strcase s))            (vl-string->list (strcase s t))        )    ))
I'm just not sure where to put the defun (LM:SentenceCase) in the code below.


--- Code - Auto/Visual Lisp: ---(vl-load-com) ;| --------------------------------Function created by unknown-------------------------------- |; (defun get-layer-filter-names (/ collection)   (setq names (list ""))  (if     (not       (vl-catch-all-error-p         (setq collection (vl-catch-all-apply                            (function                              (lambda ()                                (vla-item                                  (vla-getextensiondictionary                                    (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))                                 )                                 "ACAD_LAYERFILTERS"                               )                             )                           )                         )        )      )    )    (vlax-for item collection       (setq names (cons (strcase (vla-get-name item)) names))    )  )  names); function (get-layer-filter-names) ;; get layer filter name.. (setq layn (strcase "Stations Standard Layers"))(if (member layn names)   (princ "\nStations Standard Layers already exists.")  (command "._-layer" "filter" "Rename" "Stations Standard Layer" layn "")); if(princ)

jlogan02:
My question still stands. However, I was wanting Title Case not Sentence Case.

--- Code - Auto/Visual Lisp: ---;; Title Case - Lee Mac;; Returns the supplied string converted to Title Case (defun LM:TitleCase ( s )    (vl-list->string        (mapcar            (function                (lambda ( a b c ) (if (= 32 a) b c))            )            (cons 32 (vl-string->list s))            (vl-string->list (strcase s))            (vl-string->list (strcase s t))        )    ))
Usage (LM:TitleCase "Stations Standard Layers")

jlogan02:
Solved. Instead of using the variable
--- Code - Auto/Visual Lisp: ---layn, just spell it out like you want it.


--- Code - Auto/Visual Lisp: ---(setq layn (strcase "Stations Standard Layers"))(if (member layn names)   (princ "\nStations Standard Layers already exists.")  (command "._-layer" "filter" "Rename" "Stations Standard Layer" "Stations Standard Layers" "")

kdub:
Ahh, now I understand . . . You just want to add an 's' to a specific filter name.

. . . but you don't seem to be checking if the layerFilter you are renaming actually exists.

I assume you want to batch process drawings, or run this as part of a config routine, but you do realise that Right-click on the Filter name offers a rename option.

Regards,

added:

a piccy if 'Renamed' filter does not exist

jlogan02:
The "Stations Standard Layers already exists" message doesn't work. If the filter name exists I get...

Invalid layer filter name.
Enter new layer filter name:

This is generated by the command line syntax for the layer filter rename.


--- Code - Auto/Visual Lisp: --- (setq layn (strcase "Stations Standard Layers"))(if (member layn names)   (princ "Stations Standard Layers already exists.")  (command "._-layer" "filter" "Rename" "Stations Standard Layer" "Stations Standard Layers" "")); if(princ)
Clearly I'm wrong somewhere.

kdub, this would be in startup. Check if it exists if not add the "s"

Navigation

[0] Message Index

[#] Next page

Go to full version