Jump to content

Adding to existing LISP


PaulyPHI

Recommended Posts

Hi there, I am a bit thick when it comes to lisp files so be easy with me. I understand some commands and reasoning but then i just get lost.

I have acquired the attached LISP routine and have been using it to draw 3d sections across contours.

All i want to do is have it set the drawn 3dpolyline to a specified layer and then return to layer 0 when action is completed.

I tried finding a LISP that already selects a layer and splice that in but it fails drastically...

Any help would be appreciated.

 

Paul

Slice3d.lsp

Link to comment
Share on other sites

@PaulyPHI

Ok - Try This:

1) Right after the line with (setq usercol..., insert as shown:

   (setq usercol (acad_colordlg 10));<---Did you add this line? If so you can delete it and add the desired color to the part below.
); <----DELETE THIS Extra Right Parenthesis! program won't work with it.
   ;; Insert these lines and change the indicated values to your preference.
   ;; Make Layer if not already in drawing and set Color and Linetype.
                                   ;Layer Name|
   (if (not (tblsearch "LAYER" (setq lyr "MyLayer")))
                                  ;Color|       Linetype|
      (command "._-layer" "_m" lyr "_c" 1 lyr "_l" "Continuous" lyr "")
   )
   (setvar "clayer" "0")

Set the Layer name, Color, and Linetype to your choosing.

 

Then Replace the following line:

FROM:
(entmakex '((0 . "POLYLINE") (10 0.0 0.0 0.0) (70 . 8)))

TO:
(entmakex (list (cons 0 "POLYLINE") (list 10 0.0 0.0 0.0) (cons 70 8)(cons 8 lyr)))

 

I can't test so let me know if this is what you wanted and it works.

Edited by pkenewell
Link to comment
Share on other sites

@pkenewell many thanks for that, works perfect...

I sort of understand what each line does but each command seems cryptic rather than plain text to me.

Its all the spaces and " bits.... i wish my brain could decipher exactly what you wrote as i read it but it can't.

As i said many thanks.

Paul 

Link to comment
Share on other sites

How is this? Lots of comments to Help:

   ;; Make Layer if not already in drawing and set Color and Linetype.
   (if ;; begin If Statement.
      (not ;; Logical NOT: Returns T if test fails.
         (tblsearch ;; Function to find a value in a symbol table.
            "LAYER" ;; Table to search.
            (setq lyr "MyLayer") ;; Specify the Layer Name to Seach for and set it to a variable.
         )
      )
      ;; If no layer was found, start the LAYER command to make it.
      ;; Notes on pre-command modifiers:
      ;; "." forces the original command name, in case it has been redefined.
      ;; "_" allow command to work on non-english versions of AutoCAD.
      ;; "-" is needed on some commands to specify the command-line (no dialog) version.
      (command
         "._-layer" ;; command name.
         "_m" ;; "Make" Option.
         lyr  ;; Layer Name variable created above.
         "_c" ;; "Color" Option.
         1 ;; Integer representing the ACI color number (RED).
         lyr ;; Apply it to new Layer Name.
         "_l" ;; "Linetype" option.
         "Continuous" ;; Name of Linetype.
         lyr ;; Apply it to new Layer
         ""  ;; Empty string represents [Enter].
      ) ;; End Command
   ) ;; End If
   ;; Set the current layer to "0"
   (setvar "clayer" "0")

 

Link to comment
Share on other sites

@pkenewell i will have to take more time out from drawing poxy retaining walls and have a play at simple LISP files for my self.

 

Many thanks

 

Paul

  • Like 1
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...