seegs 发表于 2022-7-6 08:53:44

Lisp问题

豪迪·亚尔
 
我是Autolisp的初学者,已经编写了一个程序,可以在任何图形中插入任何块。这有点粗糙,但这无关紧要。它实际上工作得很好。唯一的问题是,在我运行它之后,下次我使用连接到数据库的图形时,它会失去连接。除非我用lisp程序更改文件夹名,否则我无法取回它。这是唯一的问题,(据我所知),但我真的希望它被修复。
 
以下是程序:
 


(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= _Existing MH not shown on Council GIS


B2= _Connectivity different to that shown on Council GIS


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


B4= _Install New 600mm dia. Access Chamber


B5= _Existing manhole


B6= _Node


B7= _New access chamber


B8= _Existing access chamber


B9= _House names


B10= _Road names


B11= _Pipe script


B12= _Rehab assessment number


B13= _STAMP_Tender


B14= _STAMP_Preliminary


B15= _STAMP_Issued for Construction


B16= _STAMP_As built


B17= _STAMP_Revision Stamp


B18= _Manhole


B19= _Node


B20= _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)


)

BIGAL 发表于 2022-7-6 09:07:27

我能听到尖叫声
 
键入名称有点过时,我使用菜单和sld图像,这很过时,但比记住块名要好,我们有大约200多个块

SLW210 发表于 2022-7-6 09:19:29

seegs,
 
请阅读代码发布指南并编辑您的帖子。

seegs 发表于 2022-7-6 09:30:59

很好的一点,它们中的大多数都在工具选项板中,只是散落着过时的块。我想把它们分为一类是最好的办法。我只是觉得我应该尝试一个强硬的Lisp程序例程来提高我的技能。
顺便问一下,这些菜单和sld图像是关于什么的?

seegs 发表于 2022-7-6 09:43:45

啊,我的错

BIGAL 发表于 2022-7-6 09:50:43

它与hatch中的填充图案相同,但是有了块的图片,你可以在一个标题下有多个页面,并且有很多标题,我将尝试查找上一篇文章
 
这有一个例子
 
http://www.cadtutor.net/forum/showthread.php?30342-从cad库中查找自定义程序到插入块&高亮显示=幻灯片

SLW210 发表于 2022-7-6 09:59:27

 
请编辑您的帖子。
页: [1]
查看完整版本: Lisp问题