Jump to content

How to make a existing cad command loop continuously ???


MikeP

Recommended Posts

well that didnt work. Im using a 3rd party software in cad and the command i want just goes into an endless loop that does not work when I do that

Link to comment
Share on other sites

The same as the Buzzard mentioned with the function While , you can start with things like this :)

 

(while 
  (if (and
    (setq pt (getpoint "\n Specify center of circle :"))
    (setq dia (getdist pt "\n Specify diameter of Circle :"))
    )
    (entmakex (list (cons 0 "CIRCLE")
            (cons 10 pt)
            (cons 40 dia)
            )
          )
    (princ)
    )
  )

 

Tharwat

Link to comment
Share on other sites

...you can start with things like this :)

 

FYI, no need for the IF :)

 

(setq n (trans '(0. 0. 1.) 1 0 t))

(while
 (and
   (setq p (getpoint "\nSpecify Center of Circle: "))
   (setq d (getdist p "\nSpecify Diameter of Circle: "))
 )
 (entmakex
   (list
     (cons 0 "CIRCLE")
     (cons 10 (trans p 1 n))
     (cons 40 d)
     (cons 210 n)
   )
 )
)

Link to comment
Share on other sites

I can. It works inside of cad. all the commands from this software are basically lisp

 

Mike,

 

If this is a third party app you are trying to change, I do not suggest you mess with it unless you are very experienced at lisp and also you should check if the licence agreement allows you to edit this program as well. If you want to write you own application, You should learn the basics of lisp first. You can learn it at the same site I linked you to. You can also always come here for the additional help also. What you will need to do is be more specific as to what you are trying to accomplish and we can better advise you of the direction you need to take.

 

Let us know and good luck,

The Buzzard

Link to comment
Share on other sites

One more thing to know.

 

You really do not want to hit Esc to end a program as this intentionally causes an error. If your program is written correctly and is error trapped as well as have away to end cleanly, All you really need to do is right click your mouse or press a specific key to end the program if the while loop is written properly.

 

Just some food for thought.

Link to comment
Share on other sites

If you don't have access to the third party source, it is difficult to control the loop as you have no control over the input parameters, and similarly perhaps don't know the returns of the program.

 

For example, if the program returns a non-nil value if successful (else nil if unsuccessful), a simple loop could be:

 

(while (c:MyProgram))

If this is not the case then there are few alternatives:

 

(while (not ExitFlag)
 (c:MyProgram)
 (initget "Yes No")
 (setq ExitFlag (eq "Yes" (getkword "\nExit? [Yes/No] <No> : ")))
)

 

In this case, you must ensure the variable 'ExitFlag' is localised.

(while t (c:MyProgram))

I would be reluctant to use the last example since it forces the user to hit Esc to exit the program which is bad practice in my eyes.

 

Lee

Link to comment
Share on other sites

If you don't have access to the third party source, it is difficult to control the loop as you have no control over the input parameters, and similarly perhaps don't know the returns of the program.

 

For example, if the program returns a non-nil value if successful (else nil if unsuccessful), a simple loop could be:

 

(while (c:MyProgram))

If this is not the case then there are few alternatives:

 

(while (not ExitFlag)
(c:MyProgram)
(initget "Yes No")
(setq ExitFlag (eq "Yes" (getkword "\nExit? [Yes/No] <No> : ")))
)

 

In this case, you must ensure the variable 'ExitFlag' is localised.

(while t (c:MyProgram))

I would be reluctant to use the last example since it forces the user to hit Esc to exit the program which is bad practice in my eyes.

 

Lee

 

Well said Lee.

 

It is important to get that point across.

 

Just not sure of the OP's experience.

 

I would hate to encourage someone editing a third party app if they are unsure of themselves. They are left with a program they paid for that will no longer function. It is best to show them how to build their own app. Not much lost and everything to gain.

Link to comment
Share on other sites

i want to take a command that ends and make it repeat it self untll it hit esc
A button macro starting with the * character will make that command to repeat until the user hits Esc. Does it work with external commands? :unsure:
Link to comment
Share on other sites

A button macro starting with the * character will make that command to repeat until the user hits Esc. Does it work with external commands? :unsure:

 

I have tried, but have never been successful getting this to work for external commands.

 

Steve

Link to comment
Share on other sites

You could use the vlax-add-cmd function to convert the c:CommandName defun into a "true" autocad command. Then the Multiple thingy should work. E.g. say the command is Test, then:

(setq test c:Test c:Test nil)
(vlax-add-cmd "TEST" 'test)

No need to modify the original code, just make sure the above is loaded after loading the 3rd party app.

Link to comment
Share on other sites

You could use the vlax-add-cmd function to convert the c:CommandName defun into a "true" autocad command. Then the Multiple thingy should work. E.g. say the command is Test, then:
(setq test c:Test c:Test nil)
(vlax-add-cmd "TEST" 'test)

No need to modify the original code, just make sure the above is loaded after loading the 3rd party app.

 

Nice idea - also handy if you want to run a LISP command transparently :)

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...