Jump to content

Lisp Problems


seegs

Recommended Posts

Howdee Yall

 

I'm a beginner in Autolisp, and have written a program to insert any block into any drawing. Its kinda crude, but that doesnt matter. It actually works really well. The only problem is, after I have run it, the next time I use a drawing connected to a database, it loses the connection. And I can't get it back unless I actually change the folder name with the lisp program. This is the only problem, (as far as I know) but I would really like it to be fixed.

 

Here is the program:

 


(defun c:blocks ()


 (command


   "insert"


   "S:\\9-AutoCAD\\Blocks\\Blocks_for_Tool_Palettes.dwg"


   "0,0"        "0.00001"


   "0.00001"        "0"


  )


 (command "erase" "l" "")


 (princ)


 (alert


   "Click OK then type in the code for the corresponding block you want from 
the following:


B1= [modelspace]_Existing MH not shown on Council GIS


B2= [modelspace]_Connectivity different to that shown on Council GIS


B3= [modelspace]_MH in different location to that shown on Council GIS


B4= [modelspace]_Install New 600mm dia. Access Chamber


B5= [modelspace]_Existing manhole


B6= [modelspace]_Node


B7= [modelspace]_New access chamber


B8= [modelspace]_Existing access chamber


B9= [modelspace]_House names


B10= [modelspace]_Road names


B11= [modelspace]_Pipe script


B12= [modelspace]_Rehab assessment number


B13= [paperspace]_STAMP_Tender


B14= [paperspace]_STAMP_Preliminary


B15= [paperspace]_STAMP_Issued for Construction


B16= [paperspace]_STAMP_As built


B17= [paperspace]_STAMP_Revision Stamp


B18= [paperspace]_Manhole


B19= [paperspace]_Node


B20= [paperspace]_Access Chamber"


 )


 (setq usercode (strcase (getstring "\nEnter code: ") nil))


 (cond


   ((= "B1" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command


    "-insert"


    "Existing MH not shown on Council GIS"


    userinsertionpoint


    ""


    ""


   )


    )


   )


   ((= "B2" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command


    "-insert"


    "Connectivity different to that shown on GIS"


    userinsertionpoint


    ""


    ""


   )


    )


   )


   ((= "B3" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command


    "-insert"


    "MH in different location to that shown on Council GIS"


    userinsertionpoint


    ""


    ""


   )


    )


   )


   ((= "B4" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command


    "-insert"


    "Install New 600mm dia. Access Chamber"


    userinsertionpoint


    ""


    ""


   )


    )


   )


   ((= "B5" usercode)


    (and


      (and (setq userinsertionpoint


    (getpoint "\nSpecify insertion point:")


    )


    (command "-insert"     "_ManholeExisting"


      "S"     "25.4"    userinsertionpoint


      ""      ""     ""


     )


      )


    )


   )


   ((= "B6" usercode)


    (and (setq userinsertionpoint


  (getpoint "\nSpecify insertion point:")


  )


    )


    (command "-insert"      "Model View Node"


      "s"      "0.85"     userinsertionpoint


      ""      ""      ""


     )


   )


   ((= "B7" usercode)


    (and


      (setq userinsertionpoint


      (getpoint "\nSpecify insertion point:")


      )


      (command "-insert"   "New Access Chamber"


 userinsertionpoint


      ""            ""    ""


       )


    )


   )


   ((= "B8" usercode)


    (and (setq userinsertionpoint


  (getpoint "\nSpecify insertion point:")


  )


  (command "-insert"        "Existing Access Chamber"


    userinsertionpoint  ""


    ""         ""


   )


    )


   )


   ((= "B9" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command "-insert"


    "ACMAP_ANN_TEMPLATE_House Names"


    userinsertionpoint


    "20" "20" "0"    "House Names"


   )


    )


   )


   ((= "B10" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command "-insert"   "ACMAP_ANN_TEMPLATE_Road_Name"


    userinsertionpoint  "20"


    "20"    "0" "Road_Name"


   )


    )


   )


   ((= "B11" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command "-insert"


    "ACMAP_ANN_TEMPLATE_Pipe Script"


    userinsertionpoint   "20"


    "20"     "0" "Pipe Script"


   )


    )


   )


   ((= "B12" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command


    "-insert"


    "ACMAP_ANN_TEMPLATE_Rehab Assessment No"


    userinsertionpoint        "20"


    "20"          "0" "Rehab Assessment No"


   )


    )


   )


   ((= "B13" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command "-insert" "TENDER" userinsertionpoint "" "")


    )


   )


   ((= "B14" usercode)


    (command "-insert" "PRELIMINARY" "s" "0.025" "70,60" "" "")


   )





   ((= "B15" usercode)


    (command "-insert"        "Issued for Construction"


      "s"        "0.025"  "70,60"


      ""        ""


     )


   )


   ((= "B16" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command "-insert" "AS BUILT" userinsertionpoint "" "")


    )


   )


   ((= "B17" usercode)


    (and (setq userinsertionpoint (getpoint "\nSpecify insertion 
point:"))


  (command "-insert"    "Revised Stamp" userinsertionpoint


    ""     ""     ""


   )


    )


   )


   ((= "B18" usercode)


    (and (setq userinsertionpoint


  (getpoint "\nSpecify insertion point:")


  )


  (command "-insert"        "Manhole Paperspace2"


    userinsertionpoint  "1"


    "1" "0" ""        


   )


    )


   )


   ((= "B19" usercode)


    (and (setq userinsertionpoint


  (getpoint "\nSpecify insertion point:")


  )


  (command "-insert"        "Node Paperspace"


    userinsertionpoint  


    "1"         "1" "0" ""


   )


    )


   )


   ((= "B20" usercode)


    (and (setq userinsertionpoint


  (getpoint "\nSpecify insertion point:")


  )


  (command "-insert"        "Access Chamber Paperspace"


    userinsertionpoint  "1"


    "1" "0"    ""    


   )


    )


   )


   (T (alert "That is not a valid code"))


 )


 (command "_.purge" "_all" "" "_no")


 (command "_.purge" "_all" "" "_no")


 (command "_.purge" "_all" "" "_no")


 (command "_.purge" "_all" "" "_no")


 (princ "finished")


 (princ)


)

Edited by seegs
Posting Nazis
Link to comment
Share on other sites

I can here the screaming TOOLPALLETES

 

Typing a name is a bit old fashioned I use menus and sld images which is old fashioned but better than remembering a block name we have around 200+ blocks

Link to comment
Share on other sites

Good point, & most of them are in tool palettes, just scattered around with obsolete blocks. I guess sorting them into one would be the way to go. Just thought I'd try a hardish lisp routine to up my skills.

BTW what are these menus & sld images about?

Link to comment
Share on other sites

Its the same as the hatch patterns in Hatch but with a picture of your blocks you can have multi page under 1 heading and have lots of headings, I will try to find previous post

 

this has an example

 

http://www.cadtutor.net/forum/showthread.php?30342-Looking-for-a-custom-program-to-Insert-blocks-from-a-cad-library&highlight=Slide

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