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

problem con command ("_text")

schwarz89it

Guest
good morning to all, I wrote a rudimentary function that in theory should allow me to quickly insert the "quotes" however when I arrive at the command line (command _text) the program does not properly perform the function.
Code:
(defunc c:altimetric ()
(setvar "cmdecho" 0)
(setq ps (getpoint "\point per line of writing points:"))
(setq p0 (getpoint "\report rate for calculation:"))
(setq htesto 2)
(sing)
(repeat 1)
(setq pt (getpoint "\point to be measured:"))
(setq y (- (cadr pt) (cadr p0))
(setq p1 (list (car pt) (cadr ps)))
(command "_text" "_j" p1 htesto 90 (strcat (rtos y 2 0) ")
)
)
)
I know that the most experienced of the group will tell me that it is not recommended to use command, but being at first arms, I have no particular claim to be 100% faithful to the language.Esempio1.webpthose I marked in red should be the values that should be inserted by the program, but in its place I get out of this writing:Esempio2.webpI don't know what parameters to change.
 
revised and correct
(defunc c:altimetric ()
(setvar "cmdecho" 0)
(setq ps (getpoint "\point per line of writing points:"))
(setq p0 (getpoint "\report rate for calculation:"))
(setq htesto 2)
(sing)
(setq pt (getpoint "\point to be measured:"))
(setq y (- (cadr pt) (cadr p0))
(setq p1 (list (car pt) (cadr ps)))
(command "_text" "_j" p1 htesto 90 (strcat (rtos y 2 0)))
)
)

Speaking of command, the method to use is what suits you most, in your case it's fine.
bye
 
try this way, I added the correct lines and disabled the wrong ones:
Code:
(defunc c:altimetric ()
(setvar "cmdecho" 0)
(setq ps (getpoint "\point per line of writing points:"))
(setq p0 (getpoint "\report rate for calculation:"))
(setq htesto 2)
(sing)
(repeat 1)
(setq pt (getpoint "\point to be measured:"))
 [COLOR="#FF0000"](setq and (- (cadr pt) (cadr p0)) [B]right brackets in excess[/B][/COLOR](setq y (- (cadr pt) (cadr p0))
(setq p1 (list (car pt))
 [COLOR="#FF0000"];(command "_text" "_j" "_m" p1 htesto 90 (strcat (rtos y 2 0)) "") [B]sending is redundant[/B][/COLOR]
            (command "_text" "_j" "_m" p1 htesto 90 (strcat (rtos y 2 0)))
        )
    )
    (princ) [COLOR="#FF0000"]; [B]clean exit without nil[/B][/COLOR]
)
if you want the procedure to repeat the "point to be measured" until the next sending you can remove the (repeated 1if instead such a point was always one you can remove it (while that you (repeated 1edit: I was preceded :smile:
 
Code:
(defunc c:altimetric ()
(setvar "cmdecho" 0)
(setq ps (getpoint "\point per line of writing points:"))
(setq p0 (getpoint "\report rate for calculation:"))
(setq htesto 2)
 [COLOR=#ee82ee][B](while[/B][/COLOR]
[COLOR=#0000ff][B](repeated 1[/B][/COLOR](setq pt (getpoint "\npoint da misurare:")
(setq and (- (cadr pt)[COLOR=#ff0000][B])[/B][/COLOR]
         (setq p1 (list (car pt) (cadr ps)))
         (command "_text" "_j" "_m" p1 htesto 90 (strcat (rtos y 2 0)) "")
       [B][COLOR=#0000ff])[/COLOR][/B]
[B][COLOR=#ee82ee])[/COLOR][/B] 
)
red bracket is exuberance.
I do not understand the use of a while conditional cycle and above all repeat=1 repeat. repeat should be used to repeat the same sequence several times, repeating it 1 time is only code complication.

edit: tell me:redface:! everyone to watch is discussion?? :wink:
 
Meanwhile I thank everyone for the speed with which you responded.
to respond to crystal, repeat is redundant, but when I wrote the function and tried it I noticed that the while cycle performed "only" the first two lines. evidently missed a t immediately after the command, so I introduced the repeat to obvious, fault of inexperience with this language.
 

Forum statistics

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

Members online

No members online now.
Back
Top