• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

insert a default string in getstring

  • Thread starter Thread starter Betoniera
  • Start date Start date

Betoniera

Guest
I want cofutatis, gp and other lisp magicians.
that below is an essential fragment of code that repeatedly writes a string of description and a reference line.
is used to describe the irons of the reinforced concrete sections. srive with right or left alignment depending on the tilt of the reference row.
the default string is d8/20 brackets, but it can be changed to suit.
here is the question: is it possible to obtain the predefined print of the string in the request of getstring so that you can change it without rewriting it again?
for example can I get the written d8/20 brackets already prepared so that if I want to insert brackets d10/25 cabio only the last letters?
Thank you for any suggestions
Hello, everyone.

;description staff.lsp
(if descst nil (setq descst "staffe %%c8/20"))
(setq a (strcat "\nimmetti text <" descst "> > )
descst1 (getstring t a) ; the parameter t serves to insert spaces in the text
)
(if (/= descst1") (setq descst descst1))
(setq descst2 (strcat " descst ")
)
(while (= 1 1); cycle from which it comes out
(command "_color" 3)
(setq p1 (getpoint "\nimmetti punto initial") ;first initial
p2 (getpoint p1 "\nimmetti punto label ") ;second point label
)
(command "_line" p1 p2 ")
(f) (car p2) (car p1))
(command "_text" p2 "" 0 descst2); write to the left
(command "_text" p2 "" 0 descst2); write to the right
)
);
(princ)
 
this variant of the program offers you the last inserted string.
Code:
(defunc c:staffe) ;description staff.lsp
(princ)

(if)
(setq descst1 %%%c8/20)
)

(princ descst)
(setq descst) ")); the parameter t serves to insert spaces in the text

(if (equal descst)
(setq descst descst)
)

(setq descst1 descst)
descst (strcat " descst ")
)

(while (setq p1 (getpoint "\nimmetti punto initial: ")) ; first initial
(setq p2 (getpoint p1 "\nimmetti point label: ') ; second point label
(command "_line" p1 p2 ")
(vla-put-color (vlax-ename->vla-object (entlast) 3)

(f) (car p2) (car p1))
(command "_text" p2 "" 0 descst) ;write to the left
(command "_text" p2 "" 0 descst) ; write to the right
)

)

(princ)
)
 
Hello confutatis.
I thank you for the answer, but the request was different (I knew I couldn't explain well, now I try again).
when running the program is required input in this way:

Enter text <staffe %%c8="" 20="">:

In this situation, if I want to change something, I have to reinstate the whole string.
instead I would like an input request in this way:

text < > : brackets %%c8/20

that is, I would like the user's response to be already written so that we can possibly change it without having to re-enter everything.
this would give me advantages for long and repetitive strings where maybe it changes only the diameter of the needles or the step
hello and thanks for any answers</staffe>
 
Myth falls! :biggrin::tongue::redface

You can do what you want to bake, but not the way he wants. simply approaching differently.
the various components of the final string must be divided into departure.

Pos. (or even bracket), diam and pitch must be input as single strings. after the input you "strcat" all in a unique string to pass to the sub writing of the text.
Obviously in the input phase you can repropose the previous values so that if the iron remains the same, but only the step changes, you must send to the previous demands and you answer only that of the step.
you can reproduce to video the values placed previously (e.g. diameter? : <16 )
you can change the filling characters between one value and the other depending on the values previously entered (for example st.ø8/15" in pos.1-1ø12/25). .
you can do a lot of things with lisp...:wink:
 
hi crystal, gp and confutatis.
thanks for the answers.
I figured you couldn't do it. on the other hand it is always possible to comfy the written string after its input.
or compose a shank string. Then, of course, with a dialogist box, you can do everything.
I wanted to ask only to compare experiences and see if there was a "short way" that I didn't know to prepare a response to the prompt.
but it is not an essential problem, because however we come to the result in other ways.
Hello everyone, next
 
Myth falls!
..............................


...you can do a lot of stuff with lisp...
I agree, but betoniera asked if "is it possible to get the predefined string print in the request of getstring so you can edit it without rewriting it again?", this cannot be done.

to avoid too many requests at the prompt I would not priori the hypothesis dialog box, try this example:
Code:
(defun c:pippo ( / tmp )   
    (or old (setq old "staffe ø 8/20"))
    (if
        (and
            (setq tmp (vl-filename-mktemp nil nil ".dcl"))
            (setq des (open tmp "w"))
            (foreach line
               '(
                 "ferri:dialog {"
                 "    initial_focus=\"new\";"
                 ""
                 "    : text {"
                 "    label = \"descrizione:\";"
                 "    alignment = centered;"
                 "    } "
                 ""
                 "    : edit_box {"
                 "    key=\"new\";"
                 "    allow_accept=true;"
                 "    width = 40; "
                 "    fixed_width = true; "
                 "    }"
                 "    : spacer {}"
                 "    : spacer {}"
                 "    ok_only;"
                 "}"
                )
                (write-line line des)
            )
            (not (setq des (close des)))
            (< 0 (setq dcl (load_dialog tmp)))
            (new_dialog "ferri" dcl)
        )
        (progn
            (setq new old)
            (set_tile "new" new)
            (action_tile "new" "(setq old $value)")
            (start_dialog)
        )
        (princ "\nerror loading dialog.")
    )
    (if (< 0 dcl)
        (setq dcl (unload_dialog dcl))
    )
    (if (findfile tmp)
        (vl-file-delete tmp)
    )
    (princ)
)
just use the variable new for the continuation of the lisp.

I think it is interesting, according to your preferences, to assess also the difference of behaviour in case of presence or not of " initial_focus=\"new\";"

:cool:
 
Hi.
It would be benssiom.
I, unfortunately, have a good cord with the lisp, but not with the boxes of dialogue, so I can't move on (variable new?).
I ask too much if I propose to finish the program?
I think it can also be useful to other users.
If you want to complete it and if you don't have to bring a nice lady to dinner, I'll tell you what the program should do.
what I use "complete" is the following.
the difference with the exemplified one, which I mad before, lies in the control of the height of the text.
this is the complete list (usually not use defun).

;description staff.lsp
;autocad 2013 17-09-2012

(if htds nil (setq htds 2))
(if descst nil (setq descst "staffe %%c8/20"))

(setq snp (getvar "snapomode")
ort (getvar "orthomode")
sc (getvar "dimscale")
a (strcat "\nheight of text in mm <" (rtos htds) ">: "
ht1 (getreal a)
a (strcat "\nimmetti text <" descst "> > )
descst1 (getstring t a) ; the parameter t serves to insert spaces in the text
)
(if (/= ht1 nil) (setq htds ht1))
(if (/= descst1") (setq descst descst1))
(setq descst2 (strcat " descst ")
ht (* htds 0.1 sc)
)
(command "_setvar" "textsize" ht)

(while)
(command "_setvar" "orthomode" 0)
(command "_setvar" "snapmode" 0)
(command "_color" 3)
(setq p1 (getpoint "\nimmetti punto initial") ;first initial
p2 (getpoint p1 "\nimmetti punto label ") ;second point label
)
(command "_line" p1 p2 ")
(f) (car p2) (car p1))
(command "_text" p2 "" 0 descst2); write to the left
(command "_text" p2 "" 0 descst2); write to the right
)
(command "_setvar" snp.)
(command "_setvar" ort)
);

(princ)

with the version with the dialog box, instead, you could add the input of the "htesto" variable at the top, above the writing, to be placed by default at 2 mm.
at the exit of the dialog box we should have the two htesto variables and description.
at this point begins an infinite cycle where he asks:
- point 1 of the description,
- point 2 location description,
the program draws the line and description (right or left),
again asks point 1, 2, draws the line and description, so on until the esc pressure.

the program is very thick used to describe the irons of the sections in c.a. which are quite repetitive and numerous, thus making a certain speed of execution.

I'll give you my thanks for what you can do.
Hello everyone
 
if you can be useful: inputbox variable prompt
premise txt = "roberto"
(setq txt)

the dialog box will present the roberto text ready for editing.

or:
(setq txt (listbox "a" "b" "c" "d")))
the listbox returns the value of the selection made.

These 2 functions can be used as an input form from any point of the lisp, string values return.

bye
 

Attachments

Hello rpor66
I tried listbox: it works great.
It's great because I get the input from the dialog box instead of the prompt.
is generic, so you can use it in any file program, without reprogramming the dialog box.
useless add that the default string is now editable to pleasure without having to re-enter.
I will try to complete the program to see the improvements.
Hello, thank you
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top