Jump to content

Recommended Posts

Posted

Hello! I am trying to convert a script into autolisp. I have searcht the web but i still doesn´t get the hang of it.

Problem: I have a script like this :

"INSERT
REV_TAG
0,0  
blanc line for <enter>
"

I have saved it like an .scr file, and it works perfekt if i drop it on the workspace, or via the commandline.

I would like it to start automaticly every time i launch Autocad. I have other scripts in Autolisp format that i have put in the acaddoc.lsp file and they work fine.

Insted of the .scr file i would like to learn the syntax to make a lisp file, example: (command "._layer" "_M" "NLN" "").

How would the syntax be for the "INSERT...." file if i use the lisp way?

 

/Mats

Posted

Tom_Drawer, I understand from your post that you are using that script to insert a block named "REV_TAG" (revision related probably) into your drawings – not sure about the fact that it have or not attributes; for this reason the proposed code will ignore attributes (need to set their values later). And for sure the block must be located on AutoCAD's search path.

 

(defun C:RTIns( / OldARq )
(setq OldARq (getvar "ATTREQ"))
(setvar "ATTREQ" 0)

(setvar "CMDECHO" 0)
(command "_INSERT" "REV_TAG" '(0.0 0.0) 1 1 0)

(setvar "ATTREQ" OldARq)

(princ)
)

 

To use it add the above code in your acaddoc.lsp file and call the new defined RTINS command.

Regards,

Posted

If you understand the procedure for (command "._layer" "_M" "NLN" ""), then you can easily figure out the syntax for any command style lisp macro. Just step through the command and type out what's needed. :)

Posted

Thanks msasu for a fast reply, as you guessed it is a revision tag a am trying to insert and it has some attributes, suppose i want to give the revision some attributes like this:

INSERT
REV_TAG
0,0

MEK
2009
A
2
3

How would the code in the lisp file become?

Posted

Glad you woked me up so i don´t have to go over the river for some water alanjt :D

It was in front of my face all the time. sometimes you need a kick in the a.. to get forward.

My only excuse is that i am a newbee to scripting with lisprutines.:oops:

 

/Thanks all

Posted
Glad you woked me up so i don´t have to go over the river for some water alanjt :D

It was in front of my face all the time. sometimes you need a kick in the a.. to get forward.

My only excuse is that i am a newbee to scripting with lisprutines.:oops:

 

/Thanks all

:) We all were n00bs at one point in time.

 

Don't hesitate to ask questions. It's not like you can hear our laughter. :wink:

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