Jump to content

Create new layers


SweetMidWeek

Recommended Posts

Really hoping someone can help - I'm a total noob when it comes to lisp routines (though I am trying hard to learn!)

 

I'm really struggling to get a grasp on lists and looping functions and the methods to use when putting them into practice and hoping someone can advise me.

 

The routine I'm trying to make requests two user inputs at the command line, these are:

 

1 - First plot (X), and;
2 - Final plot (Y)

 

The program then makes a layer for each of plots X, Y and all plots that range in-between the two parameters.

 

I'd ideally like the resultant layers to follow the naming convention of CP001, CP002... Etc so the final plot can be entered up to 999.

 

Is this doable? And where do I even start!! 

Link to comment
Share on other sites

If your typing X & Y to hard, do you have it in a text file csv etc if so post sample. Pretty simple task even manually.

 

Sounds like import points but with a layer twist. 

 

Edited by BIGAL
  • Like 1
Link to comment
Share on other sites

Ask user for start and end plot number. Little help from Alan , loop , and entmake function Done.

This will handle 1 - 999 or should I say 001- 999


--Edit

Added a results prompt  and alert if layers aren't created or you input a higher number for start then the end.

 

TEST
Starting Plot Number: 15
Final Plot Number: 160

Layers "CP015" Thru "CP160" Created

 

(defun C:test (/ i s lay lay list)
  (setq i (getint "\nStarting Plot Number: ")
        s (getint "\nFinal Plot Number: ")
        x (strcat "CP" (AT:NumFix (itoa i) 3))
  )
  (if (< i s) (make x))
  (while (< i s)
    (setq lay (strcat "CP" (AT:NumFix (itoa (setq i (1+ i))) 3)))
    (make lay)
  )
  (if (eq i s)
    (prompt (strcat "\nLayers \"" x "\" Thru \"" lay "\" Created"))
    (alert "Something Went wrong")
  )
  (princ)
)
(defun AT:NumFix (s n)
 ;; Fix number string with leading zeros
 ;; s - Number string to fix
 ;; n - Number of characters for final string
 ;; Alan J. Thompson, 10.29.09
 (if (< (strlen s) n)
   (AT:NumFix (strcat "0" s) n)
   s
 )
)
(defun make (lay)
  (entmake (list '(0 . "LAYER")
                 '(100 . "AcDbSymbolTableRecord")
                 '(100 . "AcDbLayerTableRecord")
                  (cons 2 lay)
                 '(6 . "Continous")
                 '(62 . 0)
                 '(70 . 0)
           )
  )
)

 

 

 

 

Edited by mhupp
  • 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...