TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: NICK_VNV on June 23, 2014, 08:44:08 AM

Title: CMDACTIVE-Pause issue with text or hatch commands
Post by: NICK_VNV on June 23, 2014, 08:44:08 AM
When I use
Code: [Select]
(command "_pline")
(while (> (getvar 'CmdActive) 0) (command pause))
...some code
everything goes OK, but when I do it with a "_-text" or "_text" or "_-hatch" instead of "_pline", these commands begin to skip some values and do not work properly, for example I can't write a text after setting insertion point for text, and can't select a method for hatching. Is there any other way to fix it, maybe i missed something?
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: ROBBO on June 23, 2014, 09:10:39 AM
these are examples of what I have used for text:

Code - Auto/Visual Lisp: [Select]
  1. (command "_.Dtext" "j" pause pause pause)(command)(command)

Code - Auto/Visual Lisp: [Select]
  1. (command "_.mtext" pause pause)(command)(command)
  2. )

Kind regards, Robbo.
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: CAB on June 23, 2014, 10:04:10 AM
Your answer is burred in the function TextAdd
No time this morning. (routine is a work in progress)
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: NICK_VNV on June 24, 2014, 12:21:40 PM
Your answer is burred in the function TextAdd
No time this morning. (routine is a work in progress)
Hmmm it's a large file with a lot of functions, it will take some time to study them :-)
And I think you mean vla-addtext function? Yes of course I can use it, or something like entmake functions, but for this time I wanted to let users run standard Autocad commands (so they see no difference in workflow) and after that make some changes in properties of newly created object. Just trying to find more simple way. If it is not possible I'll have to use vla-add.. with my propmts added or something like
these are examples of what I have used for text:

Code - Auto/Visual Lisp: [Select]
  1. (command "_.Dtext" "j" pause pause pause)(command)(command)


Code - Auto/Visual Lisp: [Select]
  1. (command "_.mtext" pause pause)(command)(command)
  2. )

Kind regards, Robbo.
with some pauses individual for each type of command.
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: CAB on June 24, 2014, 01:40:51 PM
No under the TextAdd you will find this:
Code - Auto/Visual Lisp: [Select]
  1.       ;;  layer & text size & style were Pre set
  2.       ;;  Start the COMMAND
  3.       ;;  Note strange behavior, if Leader is created prior to this command it dissapears while in this command
  4.       ;;  but reappears after command is completed.
  5.       (command "._text")
  6.       (if (/= just "L") (command "_j" just))
  7.       (command "_non")
  8.       (if (zerop (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
  9.        (command p "" (distof addAngle))
  10.        (command p (distof addAngle))
  11.       )
  12.       (while (= (logand (getvar "cmdactive") 1) 1)
  13.         (command "\\acedpause")
  14.       )
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: NICK_VNV on June 25, 2014, 07:04:35 AM
Ah you use some code instead of pauses as input parameters. But this give me the same result - function stops when it becomes time to write some text (it tries to write "pauses" for some reason). Also using \\acedpause instead of pause gives me "unkown command "\ACEDPAUSE". But I found that using (initcommandversion) before (command ..) makes this command work properly and I can normally write some text and then use it as entlast for any pusposes:
Code: [Select]
; example
(defun foo (/)
 (initcommandversion)
 (command "_dtext")
 (while (> (getvar 'CmdActive) 0) (command pause))
 (entlast)
)

(assoc 1 (entget(entlast))) ; just for check entlast's text
This also works for (command "_-hatch")
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: CAB on June 25, 2014, 07:50:58 AM
Glad you found a way.
acedpause only works within a lisp and not from the command line
Try this: User picks the point for text and then enters it.
Code: [Select]
(defun c:test ()
  (command "._text")
  (command "_non")
  (if (zerop (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
    (command  pause "" 0.0)
    (command pause 0.0)
  )
  (while (= (logand (getvar "cmdactive") 1) 1)
    (command "\\acedpause")
  )
  (princ)
)
Title: Re: CMDACTIVE-Pause issue with text or hatch commands
Post by: NICK_VNV on June 25, 2014, 08:30:21 AM
acedpause only works within a lisp and not from the command line
didn't know that, now I see your code also works for me,  thank you for help CAB!