Jump to content

The loop does not allow one of the commands to finish.


MFEC

Recommended Posts

Hello group, good morning, I come to you for help, please. I have developed a small routine that allows me to extract the length of one or more polylines and deposit it in a text. The routine asks me to enter the text size, select the polyline, and then click two points on the polyline to orient the text. but when there are many labels it is necessary to run the routine and enter the height of the text over and over again, so I decided to modify the routine by adding a loop so as not to have to repeat the process manually, however, the loop does not allow the movement to finish of the command and throws an error when it reaches another line of the routine.

What I want is for the routine to work with the loop without altering the move command line.

I attach an image of how the routine worked before adding the loop

I attach routine with the problem.

I would greatly appreciate the help

;you need a text style called MC2
(DEFUN C:TDSTX ()
(SETQ TAMA?O (GETREAL "\nDIGITE EL TAMAÑO DE LA LETRA: "))
(SETVAR "CMDECHO" 0)
(SETVAR "OSMODE" 512)
(SETVAR "ANGDIR" 0)
(SETVAR "ANGBASE" 0)
(SETQ METROS " m")
  
(setq finalizar 1)
  
( While (= finalizar 1)
  
    (PRINC "\nSELECCIONE EL LINDERO: ")
    (while (=(SETQ CONJUNTO (SSGET '((0 . "LWPOLYLINE, POLYLINE")))) nil)
      (alert "SELECCIONA EL LINDERO")
    )
    (setq VDIST	(strcat"%<\\AcExpr \("(vl-string-right-trim"+"(apply 'strcat(mapcar'(lambda (elem)(strcat	"%<\\AcObjProp Object(%<\\_ObjId "(itoa elem)">%).length>%+"))(mapcar 'vla-get-objectid(mapcar  'vlax-ename->vla-object(vl-remove-if 'listp(mapcar 'cadr (ssnamex CONJUNTO))))))))"\) \\f \"%lu2%pr2\" >%"))
    (SETQ P1 (GETPOINT "\nUBIQUE EL TEXTO"))
    (SETQ P2 (GETPOINT "\nORIENTE EL TEXTO"))
    (SETQ ANG (ANGLE P1 P2))
    (SETQ ANGULO (/(* 180 ANG) PI))
    (COMMAND "_TEXT" "_S" "MFEC2" "_J" "_MC" P1 TAMA?O ANGULO (strcat VDIST METROS))
    (SETQ CONJUNTO_SELECCION (SSGET "_L"))
    (COMMAND "MOVE" CONJUNTO_SELECCION "" P1)
    (INITGET 1 "Si No")
    (setq finalizar (GETKWORD "¿Otra etiqueta? [Si/No]:"))
    (COND
      ((= finalizar "Si") (setq finalizar 1))
      ((= finalizar "No") (setq finalizar 0))
    ) 
)
  
(SETVAR "ANGDIR" 1)
(SETVAR "ANGBASE" (* 90 (/ PI 180)))
(SETVAR "OSMODE" 13)
(COMMAND "NON")
(SETVAR "CMDECHO" 1)
);FINAL

TDSTX.LSP

Edited by MFEC
Link to comment
Share on other sites

@MFEC Your problem is you are trying to go on to the next prompt before the MOVE command is completed. Command functions need to account for all input. Use PAUSE in a command to stop and get input before continuing.

;Change This
(COMMAND "MOVE" CONJUNTO_SELECCION "" P1)

;into This
(COMMAND "MOVE" CONJUNTO_SELECCION "" P1 pause);<--- Pause here allows you to complete the command before prompting to go on to the next loop.

 

  • Thanks 1
Link to comment
Share on other sites

29 minutes ago, pkenewell said:

@MFEC Su problema es que está intentando pasar al siguiente mensaje antes de que se complete el comando MOVER. Las funciones de comando deben tener en cuenta todas las entradas. Utilice PAUSA en un comando para detenerse y obtener información antes de continuar.



		

 

Hello friend, good morning, thank you very much for the help, it has worked wonderfully for me.

  • Like 1
Link to comment
Share on other sites

Just a hint there is many label pline lisps out there one of the better ones is by Kent Cooper over at forums/autodesk, do a google.

 

There is no reason why the text can not go to say the mid point of the pline segment selected and be orientated correctly with 1 click. Hint lee-mac text readability.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...