Jump to content

Using external function within a routine


lpseifert

Recommended Posts

I must say that I am impressed Jammie... not sure where you got the idea of creating and running temporary scripts within your LISP programs, but it seems to work well! Well Done mate :)

 

Lee

Link to comment
Share on other sites

  • Replies 33
  • Created
  • Last Reply

Top Posters In This Topic

  • lpseifert

    10

  • Lee Mac

    7

  • jammie

    4

  • alanjt

    4

That works great... more than one way to skin a cat

Thanks Jammie

 

You welcome lpseifert, glad I could help . AutoCAD was just being stubborn :)

 

 

I must say that I am impressed Jammie... not sure where you got the idea of creating and running temporary scripts within your LISP programs, but it seems to work well! Well Done mate

 

Thanks Lee. It was down to a bit of trial and a lot of error really! Just trying to work with what is available and a little bit of lateral.

Link to comment
Share on other sites

Unless it has changed over the years, a script will not return control to AutoLISP. When it terminates, it stops all evaluations and return the command prompt. -David

 

Restrictions and Notes

If the SCRIPT command is used with the command function, it should be the
last function call in the AutoLISP routine.

Link to comment
Share on other sites

  • 1 year later...

I know this is an old thread, but it was linked to and I wanted to add another solution for archival purposes.

 

(vla-sendcommand
 (vla-get-activedocument (vlax-get-acad-object))
 "tcircle 1  0.3 r  ")

One has to get the prompts correct.

BTW, "\n" or " " counts as one carriage return.

Link to comment
Share on other sites

cat skinning time

(if (not bns_tcircle) (load "acettxt.lsp")) 
(setq txent (entlast))
 (setq ss1 (ssadd))
 (ssadd txent ss1)
 (bns_tcircle ss1 "Variable" "Rectangles" "" 0.30);requires selection set

BTW Alan, when I cut/pasted your code into Vlide the "l" (for last I'm assuming) came across as 1 (one). I don't know if it's a font thing or what.

 

Also, how did you determine the prompt sequence? As I read it...

Tcircle

L (last)

0.3 (offset factor)

R (rectangle)

 

but there is no prompt for "Constant/Variable" as there is when using Tcircle from the command line.

Link to comment
Share on other sites

cat skinning time

(if (not bns_tcircle) (load "acettxt.lsp")) 
(setq txent (entlast))
 (setq ss1 (ssadd))
 (ssadd txent ss1)
 (bns_tcircle ss1 "Variable" "Rectangles" "" 0.30);requires selection set

BTW Alan, when I cut/pasted your code into Vlide the "l" (for last I'm assuming) came across as 1 (one). I don't know if it's a font thing or what.

 

Also, how did you determine the prompt sequence? As I read it...

Tcircle

L (last)

0.3 (offset factor)

R (rectangle)

 

but there is no prompt for "Constant/Variable" as there is when using Tcircle from the command line.

 

It's an 1 (one) not L. I just copied what prompts were displayed in an earlier post. For that, a selection must be active (sssetfirst).

 

There's a few examples of me abusing vla-sendcommand floating around.

 

:)

Precisely. :)

Link to comment
Share on other sites

Gotcha, thanks. I never knew a double space was read as an Enter.

It doesn't. One space or "\n" counts as an enter. However, using vla-sendcommand is just like using a script. You have to include a carriage return for each value entered.

If you put "e" it will just print "e" at the command line. However, if you send "e " or "e\n" it will act as if you just type "E" and hit enter, which will execute Erase.

Link to comment
Share on other sites

  • 2 years later...

I'm having trouble getting this to work.

 

 
(defun c:revtxt ()
 (vl-load-com)

 (setq os (getvar "osmode"))
 (setq pt  (getpoint "\nSpecify start point of text :")
str (getstring t "\nType text :")
 )
 (vl-cmdf "text" pt "" "" str)
 (setvar "osmode" 0)
 (setq fname (vl-filename-mktemp "c:\acad_ipco\Control2008\macro\slot")
file  (open fname "w")
 )
 (foreach n (list "tcircle"
    "l"
    ""
    "0.35"
    "s"
    "c"
    "b"
     ""
     )
   (write-line n file)
 )
 (close file)
 (vl-cmdf "script" "slot")
 (vl-file-delete "slot")
 (setvar "osmode" os)
)

 

My command line sequence is here. Where is the 3.5 coming from and why is it not selecting the text as the selection set states?

 

Command: (LOAD "C:/acad_ipco/Control2008/slot.lsp") C:REVTXT

Command: REVTXT

Specify start point of text :

Type text :12345

0

Command: tcircle

Select TEXT, MTEXT or ATTDEF objects...

Select objects: 3.5 - Should be selecting "last" object

 

*Invalid selection*

Expects a point or

Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/P

revious/Undo/AUto/SIngle

Select objects: 1 found

Select objects:

Enter distance offset factor : asks for user inputs here. should just enter those inputs via the script.

Enclose text with [Circles/Slots/Rectangles] :

Create slots of constant or variable size [Constant/Variable] :

Creating Slots...Done.

 

Any suggestions on what the issue is?

Thanks

JD

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