Discussion Groups

All Discussion Groups » AutoCAD 2008

Thread: Syntax for script file to insert blocks with attributes


Permlink Replies: 8 - Last Post: Jan 11, 2009 6:15 PM Last Post By: Gordough
Gordough

Posts: 54
Registered: 12/05/07
Syntax for script file to insert blocks with attributes
Posted: Jan 8, 2009 5:12 PM
  Click to reply to this thread Reply




I'm having difficulty in getting the right syntax in a script file for inserting survey point blocks with attributes. The block is simply a node with 3 attributes for point number, elevation and description.







Below sample line from the script doesn't work properly:







-insert spnt 5608116.302,371366.6888 1 1 0 P1 14.6014 TOE







Below sample lines do work properly (read further below):







-insert spnt 5608116.302,371366.6888 1 1 0 P1



14.6014



TOE











spnt is the point block



P1 is the point number attribute



14.6014 is the elevation attribute



TOE is the description attribute







System variable ATTREQ = 1



ATTDIA=0







The block is inserted in the drawing ok except the point number, elevation and description is read as the first attribute value. The remaining attributes take on their default value. See attached sample of point block.







I can get it to work properly if I place the elevation and description attribute on a separte line. The problem is that I have hundreds of points that are taken from an excel spreadsheet and saved into a notepad script file as ascii text. I would have to edit each point in the script to place the elevation and description on a separate line which is too time consuming and somewhat defeats the purpose of using a script.



Is their some way of possibly placing a carriage return control character between the point number, elevation and description to fool autocad in thinking that they are on a separate line in the script file?







Any help or suggestion would be much appreciated.

George Drayton
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 8, 2009 10:32 PM   in response to: Gordough in response to: Gordough
  Click to reply to this thread Reply
It would be a good idea to use semicolons instead of spaces for the
"enter" keys 0 then you can sure that you have exactly the correct
number. Your macro looks OK in principle but when you run it you need
to look at the command line and see what/where the error is. You can
cust and paste form the AutoCAD text screen to a message here. If the
attribures hace spaces you need to put them in quotes e.g. "test 1".

George Drayton CD-CAD Ltd Christchurch New Zealand
Gordough

Posts: 54
Registered: 12/05/07
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 10, 2009 12:04 AM   in response to: George Drayton in response to: George Drayton
  Click to reply to this thread Reply
Thanks for your reply. Since I posted the first message I found another way to get all of the attributes on the same line. I wrote a one line autolisp expression instead. I seems to work just fine.

Thanks again
Gordough

Posts: 54
Registered: 12/05/07
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 10, 2009 5:25 PM   in response to: George Drayton in response to: George Drayton
  Click to reply to this thread Reply
Can you please explain to me how a semicolon is used in a script to behave like hitting the return key? This does not work for me. As far as I know semicolons are used for commenting text in a script file.
Gehenna
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 10, 2009 7:04 PM   in response to: Gordough in response to: Gordough
  Click to reply to this thread Reply
Gordough wrote:
Can you please explain to me how a semicolon is used in a script to
behave like hitting the return key? This does not work for me. As far as
I know semicolons are used for commenting text in a script file.

Semicolons ARE the same as Enter key in a script file - as well as a
space. Use of them is other type files are for commenting.
Gordough

Posts: 54
Registered: 12/05/07
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 11, 2009 2:03 AM   in response to: Gehenna in response to: Gehenna
  Click to reply to this thread Reply
I won't believe it unless I see it. Can you please show me an example.

Thanks.
Gehenna
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 11, 2009 4:58 AM   in response to: Gordough in response to: Gordough
  Click to reply to this thread Reply
Gordough wrote:
I won't believe it unless I see it. Can you please show me an example.
Thanks.

Here's one - note last line with spaces are same as pressing the Enter key.
; ARCLEADR.LSP
; DRAWS ARC WITH STANDARD ARROW HEAD
(defun c:arcleadr (/ startpnt anglepnt endpnt1 endpnt2)
(graphscr)
(command "cmdecho" 0)
(initget 15)
(setq startpnt (getpoint
"\nStarting point for arrow: "))
(setq anglepnt
(getpoint startpnt
"\nSelect angle definition point: ")
)
(setq endpnt1
(polar
startpnt
(angle startpnt anglepnt)
(* 0.1875 (getvar "ltscale"))
)
)
(setq endpnt2 (* 0.0625 (getvar "ltscale")))
(command "pline" startpnt "w" "0.0" endpnt2 endpnt1
"w" "0.0" "0.0" "arc"
)
(princ))
(command "-layer" "s" "0" "")
Murph
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 11, 2009 2:58 PM   in response to: Gehenna in response to: Gehenna
  Click to reply to this thread Reply
That looks like a lisp file not a script file.

--
Murph
www.map3d.wordpress.com


"Gehenna" wrote in message
news:6102336@discussion.autodesk.com...
Gordough wrote:
I won't believe it unless I see it. Can you please show me an example.
Thanks.

Here's one - note last line with spaces are same as pressing the Enter key.
; ARCLEADR.LSP
; DRAWS ARC WITH STANDARD ARROW HEAD
(defun c:arcleadr (/ startpnt anglepnt endpnt1 endpnt2)
(graphscr)
(command "cmdecho" 0)
(initget 15)
(setq startpnt (getpoint
"\nStarting point for arrow: "))
(setq anglepnt
(getpoint startpnt
"\nSelect angle definition point: ")
)
(setq endpnt1
(polar
startpnt
(angle startpnt anglepnt)
(* 0.1875 (getvar "ltscale"))
)
)
(setq endpnt2 (* 0.0625 (getvar "ltscale")))
(command "pline" startpnt "w" "0.0" endpnt2 endpnt1
"w" "0.0" "0.0" "arc"
)
(princ))
(command "-layer" "s" "0" "")
Gordough

Posts: 54
Registered: 12/05/07
Re: Syntax for script file to insert blocks with attributes
Posted: Jan 11, 2009 6:11 PM   in response to: Gehenna in response to: Gehenna
  Click to reply to this thread Reply
Thanks for your response.

I don't see your point about the spaces you mentioned on the last line. This is an autolisp statement and there are no spaces.

I guess I'm not making myself clear enough. I didn't want an autolisp but rather a true script similar to how you would input on the command line or like a menu macro. I hope this is clear.

Thanks again.

Cheers
Gordough

Edited by: Gordough on Jan 11, 2009 10:13 AM