Jump to content

Quotes within quotes when writing a lisp issue


Recommended Posts

Posted

I am writing a lisp file to set up my title blocks and scales to make it faster to choose the paper size and scale to set the drawing at. I pretty much just go between two paper sizes so I drew one view port for an E size sheet then draw just a rectangle centered in the viewport representing a D size sheet to help figure out the best scale and sheet size to use in this lisp.

 

My issue is that I want to add all the scales that I use with the lisp routine also but how I would typically involves adding "quotes" within quotes that are just meant to be text. Does anyone know how I could write this so it will work? Any help would be appreciated.

 

 

This is an example of the commands i am having issues with:

(command "-scalelistedit" "a" "1" = 50'-0" "1:600" "e")

 

 

Also, I know I don't have to keep exiting the command "scalelistedit" and entering to add multiple scales I just was doing it this way preliminarily.

 

(defun c:tbss(/ point1 point2 point3 point4 )
(setvar "cmdecho" 0)
(command ".-layer" "n" "G-Vprt" "") 
(command ".-layer" "c" "211" "G-Vprt" "")
(command ".-layer" "p" "n" "G-Vprt" "")
(command ".layout" "s" "")
(setq old_clayer (getvar "clayer"))
(command ".-layer" "S" "G-Vprt" "")
(setq point1 (list 0.5 0.3125 0.0) point2 (list 37.7875 29.2275 0.0))
(setq point3 (list 3.1438 3.3638 0.0) point4 (list 35.1438 26.1762 0.0))
(command ".-vports" point1 point2)
(command "rectangle" point3 point4)
(command "-scalelistedit" "a" "1" = 1'-0" "1:12" "e")
(command "-scalelistedit" "a" "1/2" = 1'-0" "0.5:12" "e")
(command "-scalelistedit" "a" "1/4" = 1'-0" "0.25:12" "e")
(command "-scalelistedit" "a" "3/16" = 1'-0" "0.01875:12" "e")
(command "-scalelistedit" "a" "1/8" = 1'-0" "0.125:12" "e")
(command "-scalelistedit" "a" "3/32" = 1'-0" "0.09375:12" "e")
(command "-scalelistedit" "a" "1/16" = 1'-0" "0.0625:12" "e")
(command "-scalelistedit" "a" "1/32" = 1'-0" "0.03125:12" "e")
(command "-scalelistedit" "a" "1/64" = 1'-0" "0.015625:12" "e")
(command "-scalelistedit" "a" "1" = 10'-0" "1:120" "e")
(command "-scalelistedit" "a" "1" = 20'-0" "1:240" "e")
(command "-scalelistedit" "a" "1" = 30'-0" "1:360" "e")
(command "-scalelistedit" "a" "1" = 40'-0" "1:480" "e")
(command "-scalelistedit" "a" "1" = 50'-0" "1:600" "e")
(command "-layer" "S" old_clayer "")
(setvar "cmdecho" 1)
(princ)
)

(prompt "Title Block and Scale Setup Loaded.")

Posted

You will need to use the backslash escape character:

 

(princ "\nA quote: \"")

In your example:

 

(command "_.-scalelistedit" "_a" "1\" = 50'-0" "1:600" "_e")

Posted

Use

(command "-scalelistedit" "a" "1 = 1'-0\"" "1:12" "e")

To add multiple values you can use

(command "-scalelistedit"
           "a" "1 = 1'-0\"" "1:12"
           "a" "1/2 = 1'-0\"" "0.5:12"
           ...
           "e")  

To find out correct input required for any (command ... ), just type the command without any argument and watch command line prompt:

Command: (command "-scalelistedit")
-scalelistedit Enter option [?/Add/Delete/Reset/Exit] <Add>: nil
Enter option [?/Add/Delete/Reset/Exit] <Add>: [b]a[/b]
Enter name for new scale: [b]NewName[/b]
Enter scale ratio: [b]1:12.5[/b]
Enter option [?/Add/Delete/Reset/Exit] <Add>: [b]e[/b]

Posted

Thanks Lee that worked great!

 

Here is my end result incase anyone is interested. Like I said before it isn't neccessary to close out the scalelistedit command and reinitiate it but it's just how I did it and it works. Obviously you would have to adjust the points to suite your own titlblock and adjust the layer to your own but if you like the idea it might work for you.

 

(defun c:tbss(/ point1 point2 point3 point4 )
(setvar "cmdecho" 0)
(command "_.-layer" "n" "G-Vprt" "") 
(command "_.-layer" "c" "211" "G-Vprt" "")
(command "_.-layer" "p" "n" "G-Vprt" "")
(command "_.layout" "s" "")
(setq old_clayer (getvar "clayer"))
(command ".-layer" "S" "G-Vprt" "")
(setq point1 (list 0.5 0.3125 0.0) point2 (list 37.7875 29.2275 0.0))
(setq point3 (list 3.1438 3.3638 0.0) point4 (list 35.1438 26.1762 0.0))
(command ".-vports" point1 point2)
(command "rectangle" point3 point4)
(command "_.-scalelistedit" "a" "1\" = 1'-0" "1:12" "_e")
(command "_.-scalelistedit" "a" "1/2\" = 1'-0" "0.5:12" "_e")
(command "_.-scalelistedit" "a" "1/4\" = 1'-0" "0.25:12" "_e")
(command "_.-scalelistedit" "a" "3/16\" = 1'-0" "0.01875:12" "_e")
(command "_.-scalelistedit" "a" "1/8\" = 1'-0" "0.125:12" "_e")
(command "_.-scalelistedit" "a" "3/32\" = 1'-0" "0.09375:12" "_e")
(command "_.-scalelistedit" "a" "1/16\" = 1'-0" "0.0625:12" "_e")
(command "_.-scalelistedit" "a" "1/32\" = 1'-0" "0.03125:12" "_e")
(command "_.-scalelistedit" "a" "1/64\" = 1'-0" "0.015625:12" "_e")
(command "_.-scalelistedit" "a" "1\" = 10'-0" "1:120" "_e")
(command "_.-scalelistedit" "a" "1\" = 20'-0" "1:240" "_e")
(command "_.-scalelistedit" "a" "1\" = 30'-0" "1:360" "_e")
(command "_.-scalelistedit" "a" "1\" = 40'-0" "1:480" "_e")
(command "_.-scalelistedit" "a" "1\" = 50'-0" "1:600" "_e")
(command "_.-layer" "S" old_clayer "")
(setvar "cmdecho" 1)
(princ "\nA quote: \"")
)

(prompt "Title Block and Scale Setup Loaded.")

Posted
Use

(command "-scalelistedit" "a" "1 = 1'-0\"" "1:12" "e")

To add multiple values you can use

(command "-scalelistedit"
"a" "1 = 1'-0\"" "1:12"
"a" "1/2 = 1'-0\"" "0.5:12"
...
"e") 

To find out correct input required for any (command ... ), just type the command without any argument and watch command line prompt:

Command: (command "-scalelistedit")
-scalelistedit Enter option [?/Add/Delete/Reset/Exit] <Add>: nil
Enter option [?/Add/Delete/Reset/Exit] <Add>: [b]a[/b]
Enter name for new scale: [b]NewName[/b]
Enter scale ratio: [b]1:12.5[/b]
Enter option [?/Add/Delete/Reset/Exit] <Add>: [b]e[/b]

 

Yea maybe I will edit it to work that way instead. I wasn't 100% sure how to write it like that and I was in a hurry so i just did it how I knew would work. Thanks.

Posted

Here it is.

 

(defun c:tbss(/ point1 point2 point3 point4 )
(setvar "cmdecho" 0)
(command "_.-layer" "n" "G-Vprt" "") 
(command "_.-layer" "c" "211" "G-Vprt" "")
(command "_.-layer" "p" "n" "G-Vprt" "")
(command "_.layout" "s" "")
(setq old_clayer (getvar "clayer"))
(command ".-layer" "S" "G-Vprt" "")
(setq point1 (list 0.5 0.3125 0.0) point2 (list 37.7875 29.2275 0.0))
(setq point3 (list 3.1438 3.3638 0.0) point4 (list 35.1438 26.1762 0.0))
(command "_.-vports" point1 point2)
(command "rectangle" point3 point4)
(command "_.-scalelistedit" "a" "1\" = 1'-0" "1:12"
                            "a" "1/2\" = 1'-0" "0.5:12"
                            "a" "1/4\" = 1'-0" "0.25:12"
                            "a" "3/16\" = 1'-0" "0.01875:12"
                            "a" "1/8\" = 1'-0" "0.125:12"
                            "a" "3/32\" = 1'-0" "0.09375:12"
                            "a" "1/16\" = 1'-0" "0.0625:12"
                            "a" "1/32\" = 1'-0" "0.03125:12"
                            "a" "1/64\" = 1'-0" "0.015625:12"
                            "a" "1\" = 10'-0" "1:120"
                            "a" "1\" = 20'-0" "1:240"
                            "a" "1\" = 30'-0" "1:360"
                            "a" "1\" = 40'-0" "1:480"
                            "a" "1\" = 50'-0" "1:600" "_e")
(command "_.-layer" "S" old_clayer "")
(setvar "cmdecho" 1)
(princ "\nA quote: \"")
)

(prompt "Title Block and Scale Setup Loaded.")

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