(defun nnnn (nek / ss dana)(if (setq ss (ssget "x" (list (cons 0 "text,mtext") (cons 8 nek)))) (setq dana (dxf 1(entget (ssname s 0)))) (setq dana "0" )) (if (numberp dana) (setq dana (rtos dana 2 2)) (setq dana dana) ) (princ (strcat "\n " nek " --> " dana))dana)(defun c:wer ( / a b c d)(setq a (nnnn "layer1"))(setq b (nnnn "layer2"))(setq c (nnnn "layer3"))(setq d (nnnn "layer4")).....)
Sure, it can be easier to write so please help. Sure, it can be avoided in some way to repeatedly search the drawing database, but do not know how. This function is used to download the text of a particular layer.
Forgive me, but it is hard to understand what it is you're asking for exactly...
I believe that you're wanting a sub-function that accepts a layer name argument as string, and are attempting to return a list of text strings for all Mtext and Text entities on the argument layer. If so, these may help:
I use this function:
"(nnnn "layer1")" about 40 times in my program.
Each time searching the base drawing.
The question is: is it necessary, it may be easier.
Without more information it is hard to know for sure... However, redundancy is generally not a good practice, unless necessary.
If the purpose of your function is extract information, then simply store the extracted information to a variable and query, or manipulate the variable thereafter.
Just as long as that "data" is not a selection set. From the OP it seems to be. I'd highly advise against saving a selection set into a global variable.
From the nnnn function it appears you simply want to list the 1st text placed on the specified layer - to the command line. You might save just that text's ename, but then what if it's erased / changed to a different layer?
Again, we require some more info on what you're trying to accomplish. We might be pointing you into a direction which could cause problems down the line. It's for your own benefit to explain as clearly as possible for us hard-of-understanding people
Sorry it's probably the language difficulties.
The idea is this:
- Creating drawings of interest to me put the data on specific layers.
- Then using Lisp takes this data and somehow, further transformed (multiplying, dividing by typing in other places).