乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 13|回复: 13

[编程交流] 将choose选项添加到lisp

[复制链接]

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 13:10:29 | 显示全部楼层 |阅读模式
我有一个Lisp程序的Lisp程序,告诉我线的长度。
但它只在厘米中显示。
我希望它会问我是用米还是厘米表示。
类似这样的选项可供选择
141032gy664v62w0z4c0l0.png
我希望你能帮我
  1. (defun increment (str / )
  2. (if (= mynumber nil) (setq mynumber 0))
  3. (setq mynumber (+ mynumber 1))
  4. (princ "\Current Number :<")(princ mynumber)
  5.         (setq askw (getint "> : "))
  6.         (if (/= askw nil)(setq mynumber askw))
  7.         (vl-string-subst (itoa mynumber) "*" str)
  8. )
  9. ;;-------------------------=={ Length Field }==-------------------------;;
  10. ;;                                                                      ;;
  11. ;;  This program allows a user to generate a field expression           ;;
  12. ;;  referencing the length/perimeter/circumference of one or more       ;;
  13. ;;  selected objects. In the case of selecting multiple objects, the    ;;
  14. ;;  field expression will reference the sum of the lengths of all       ;;
  15. ;;  objects in the selection.                                           ;;
  16. ;;                                                                      ;;
  17. ;;  The user may opt to specify a point at which to create a new        ;;
  18. ;;  multiline text object housing the field expression, pick a table    ;;
  19. ;;  cell in which the field should be inserted, or select an existing   ;;
  20. ;;  single-line text, multiline text, multileader, or attribute to      ;;
  21. ;;  be populated with the field expression.                             ;;
  22. ;;                                                                      ;;
  23. ;;  Upon issuing the command syntax 'LF' (Length Field) at the AutoCAD  ;;
  24. ;;  command-line, the program first prompts the user to make a          ;;
  25. ;;  selection of objects for which to return the length summation.      ;;
  26. ;;                                                                      ;;
  27. ;;  At this prompt, the user may select any number of Arcs, Circles,    ;;
  28. ;;  Lines, 2D Polylines (light or heavy), or 3D Polylines.              ;;
  29. ;;                                                                      ;;
  30. ;;  The user is then prompted to specify a point or table cell to       ;;
  31. ;;  insert a field expression referencing the summation of the lengths  ;;
  32. ;;  of the selected objects.                                            ;;
  33. ;;                                                                      ;;
  34. ;;  At this prompt, the user may also choose the 'Object' option in     ;;
  35. ;;  order to populate the content of an existing annotation object      ;;
  36. ;;  with the field expression.                                          ;;
  37. ;;                                                                      ;;
  38. ;;  Upon choosing this option, the user may select any single-line      ;;
  39. ;;  text (DText), multiline text (MText), single-line or multiline      ;;
  40. ;;  attribute, attributed block, or multileader (MLeader) with either   ;;
  41. ;;  multiline text or attributed block content.                         ;;
  42. ;;                                                                      ;;
  43. ;;  If the user selects an attributed block or attributed multileader   ;;
  44. ;;  with more than one attribute, the user is presented with a dialog   ;;
  45. ;;  interface listing the available attributes, and is prompted to      ;;
  46. ;;  select a destination for the field expression.                      ;;
  47. ;;                                                                      ;;
  48. ;;  The user may optionally predefine the target block/multileader      ;;
  49. ;;  attribute by specifying the attribute tag where noted at the top    ;;
  50. ;;  of the program source code.                                         ;;
  51. ;;                                                                      ;;
  52. ;;  The resulting field expression will display the sum of the lengths  ;;
  53. ;;  of the selected objects, formatted using the field formatting code  ;;
  54. ;;  specified at the top of the program.                                ;;
  55. ;;                                                                      ;;
  56. ;;----------------------------------------------------------------------;;
  57. ;;  Author:  Lee Mac, Copyright © 2017  -  www.lee-mac.com              ;;
  58. ;;----------------------------------------------------------------------;;
  59. ;;  Version 1.0    -    2017-08-06                                      ;;
  60. ;;                                                                      ;;
  61. ;;  - First release.                                                    ;;
  62. ;;----------------------------------------------------------------------;;
  63. ;;  Version 1.1    -    2017-08-06                                      ;;
  64. ;;                                                                      ;;
  65. ;;  - Program modified to account for selection of existing annotation  ;;
  66. ;;    objects which already contain a field expression.                 ;;
  67. ;;----------------------------------------------------------------------;;
  68. (defun c:lf ( / *error* ent enx flg fmt idx lst obj oid prp sel str tab tag tmp typ )
  69.     (setq fmt "L*=%lu6%pr2 cm") ;; Field Formatting
  70.     (setq
  71.           fmt (increment fmt)
  72.           tag nil    ;; Optional predefined attribute tag
  73.     )
  74.    
  75.     (defun *error* ( msg )
  76.         (LM:endundo (LM:acdoc))
  77.         (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
  78.             (princ (strcat "\nError: " msg))
  79.         )
  80.         (princ)
  81.     )
  82.     (LM:startundo (LM:acdoc))
  83.     (setq prp
  84.        '(
  85.             ("AcDbArc"        . "ArcLength")
  86.             ("AcDbCircle"     . "Circumference")
  87.             ("AcDbLine"       . "Length")
  88.             ("AcDbPolyline"   . "Length")
  89.             ("AcDb2dPolyline" . "Length")
  90.             ("AcDb3dPolyline" . "Length")
  91.         )
  92.     )
  93.     (if
  94.         (setq sel
  95.             (LM:ssget "\nSelect objects to obtain total length <exit>: "
  96.                 (list
  97.                     (list
  98.                        '(000 . "ARC,CIRCLE,LINE,*POLYLINE")
  99.                        '(-04 . "<NOT")
  100.                            '(-04 . "<AND")
  101.                                '(000 . "POLYLINE") '(-04 . "&") '(070 . 80)
  102.                            '(-04 . "AND>")
  103.                        '(-04 . "NOT>")
  104.                         (if (= 1 (getvar 'cvport))
  105.                             (cons 410 (getvar 'ctab))
  106.                            '(410 . "Model")
  107.                         )
  108.                     )
  109.                 )
  110.             )
  111.         )
  112.         (progn
  113.             (if (= 1 (sslength sel))
  114.                 (setq obj (vlax-ename->vla-object (ssname sel 0))
  115.                       str
  116.                     (strcat
  117.                         "%<\\AcObjProp Object(%<\\_ObjId "
  118.                         (LM:objectid obj)
  119.                         ">%)." (cdr (assoc (vla-get-objectname obj) prp)) " \\f "" fmt "">%"
  120.                     )
  121.                 )
  122.                 (progn
  123.                     (repeat (setq idx (sslength sel))
  124.                         (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))
  125.                               lst
  126.                             (vl-list*
  127.                                 "%<\\AcObjProp Object(%<\\_ObjId "
  128.                                 (LM:objectid obj)
  129.                                 ">%)." (cdr (assoc (vla-get-objectname obj) prp)) ">%" " + "
  130.                                 lst
  131.                             )
  132.                         )
  133.                     )
  134.                     (setq str
  135.                         (strcat
  136.                             "%<\\AcExpr "
  137.                             (apply 'strcat (reverse (cdr (reverse lst))))
  138.                             " \\f "" fmt "">%"
  139.                         )
  140.                     )
  141.                 )
  142.             )
  143.             (if
  144.                 (setq tmp
  145.                     (ssget "_X"
  146.                         (list '(0 . "ACAD_TABLE")
  147.                             (if (= 1 (getvar 'cvport))
  148.                                 (cons 410 (getvar 'ctab))
  149.                                '(410 . "Model")
  150.                             )
  151.                         )
  152.                     )
  153.                 )
  154.                 (repeat (setq idx (sslength tmp))
  155.                     (setq tab (cons (vlax-ename->vla-object (ssname tmp (setq idx (1- idx)))) tab))
  156.                 )
  157.             )
  158.             (while
  159.                 (not
  160.                     (progn
  161.                         (if flg
  162.                             (progn
  163.                                 (setvar 'errno 0)
  164.                                 (initget "Point eXit")
  165.                                 (setq sel (nentsel "\nSelect text, mtext, mleader, attribute or attributed block [Point/eXit] <eXit>: "))
  166.                             )
  167.                             (progn
  168.                                 (initget "Object eXit")
  169.                                 (setq sel (getpoint "\nSpecify point or cell for field [Object/eXit] <eXit>: "))
  170.                             )
  171.                         )
  172.                         (cond
  173.                             (   (= 7 (getvar 'errno))
  174.                                 (prompt "\nMissed, try again.")
  175.                             )
  176.                             (   (or (null sel) (= "eXit" sel)))
  177.                             (   (= "Point" sel)
  178.                                 (setq flg nil)
  179.                             )
  180.                             (   (= "Object" sel)
  181.                                 (not (setq flg t))
  182.                             )
  183.                             (   flg
  184.                                 (setq ent (car sel)
  185.                                       enx (entget ent)
  186.                                       typ (cdr (assoc 0 enx))
  187.                                       obj (vlax-ename->vla-object ent)
  188.                                 )
  189.                                 (cond
  190.                                     (   (and (= 2 (length sel)) (wcmatch typ "TEXT,MTEXT"))
  191.                                         (if (vlax-write-enabled-p obj)
  192.                                             (LF:puttextstring obj str)
  193.                                             (prompt "\nThe selected text object is on a locked layer.")
  194.                                         )
  195.                                     )
  196.                                     (   (and (= "ATTRIB" typ)
  197.                                              (/= 'str (type tag))
  198.                                         )
  199.                                         (if (vlax-write-enabled-p obj)
  200.                                             (progn
  201.                                                 (LF:puttextstring obj str)
  202.                                                 (LF:updatefield ent)
  203.                                             )
  204.                                             (prompt "\nThe selected attribute is on a locked layer.")
  205.                                         )
  206.                                     )
  207.                                     (   (and
  208.                                             (or
  209.                                                 (and (= "ATTRIB" typ)
  210.                                                      (setq tmp (cdr (assoc 330 enx)))
  211.                                                 )
  212.                                                 (and (setq tmp (last (cadddr sel)))
  213.                                                      (= "INSERT" (cdr (assoc 0 (entget tmp))))
  214.                                                 )
  215.                                             )
  216.                                             (setq tmp (vlax-invoke (vlax-ename->vla-object tmp) 'getattributes))
  217.                                             (or
  218.                                                 (and (= 'str (type tag))
  219.                                                      (setq idx (vl-position (strcase tag) (mapcar 'vla-get-tagstring tmp)))
  220.                                                      (setq obj (nth idx tmp))
  221.                                                 )
  222.                                                 (and (not (cdr tmp))
  223.                                                      (setq obj (car tmp))
  224.                                                 )
  225.                                                 (and (setq idx (LM:listbox "Choose Attribute" (mapcar 'vla-get-tagstring tmp) 2))
  226.                                                      (setq obj (nth (car idx) tmp))
  227.                                                 )
  228.                                             )
  229.                                         )
  230.                                         (if (vlax-write-enabled-p obj)
  231.                                             (progn
  232.                                                 (LF:puttextstring obj str)
  233.                                                 (LF:updatefield (vlax-vla-object->ename obj))
  234.                                             )
  235.                                             (prompt "\nThe selected attribute is on a locked layer.")
  236.                                         )
  237.                                     )
  238.                                     (   (and (= 2 (length sel)) (= "MULTILEADER" typ))
  239.                                         (setq typ (cdr (assoc 172 (reverse enx))))
  240.                                         (cond
  241.                                             (   (and (<= acblockcontent typ acmtextcontent) (not (vlax-write-enabled-p obj)))
  242.                                                 (prompt "\nThe selected multileader is on a locked layer.")
  243.                                             )
  244.                                             (   (= acmtextcontent typ)
  245.                                                 (LF:puttextstring obj str)
  246.                                                 (vla-regen (LM:acdoc) acactiveviewport)
  247.                                                 t
  248.                                             )
  249.                                             (   (and
  250.                                                     (= acblockcontent typ)
  251.                                                     (setq tmp (LM:getmleaderattributes obj))
  252.                                                     (or
  253.                                                         (and (= 'str (type tag))
  254.                                                              (setq oid (cdr (assoc (strcase tag) tmp)))
  255.                                                         )
  256.                                                         (and (not (cdr tmp))
  257.                                                              (setq oid (cdar tmp))
  258.                                                         )
  259.                                                         (and (setq idx (LM:listbox "Choose Attribute" (mapcar 'car tmp) 2))
  260.                                                              (setq oid (cdr (nth (car idx) tmp)))
  261.                                                         )
  262.                                                     )
  263.                                                 )
  264.                                                 (LM:setmleaderattributevalue obj oid str)
  265.                                                 (vla-regen (LM:acdoc) acactiveviewport)
  266.                                                 t
  267.                                             )
  268.                                             (   (prompt "\nThe select multileader has no editable content."))
  269.                                         )
  270.                                     )
  271.                                     (   (prompt "\nThe selected object is not text, mtext, multileader, attribute or attributed block."))
  272.                                 )
  273.                             )
  274.                             (   (setq tmp (LM:getcell tab (trans sel 1 0)))
  275.                                 (if (vlax-write-enabled-p (car tmp))
  276.                                     (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-settext (append tmp (list str)))))
  277.                                     (prompt "\nThe selected table cell belongs to a table on a locked layer.")
  278.                                 )
  279.                             )
  280.                             (   (vla-addmtext
  281.                                     (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
  282.                                     (vlax-3D-point (trans sel 1 0))
  283.                                     0.0
  284.                                     str
  285.                                 )
  286.                             )
  287.                         )
  288.                     )
  289.                 )
  290.             )
  291.         )
  292.     )
  293.     (*error* nil) (princ)
  294. )
  295. (defun LF:puttextstring ( obj str )
  296.     (vla-put-textstring obj "") ;; To clear any existing field
  297.     (vla-put-textstring obj str)
  298.     t
  299. )
  300. (defun LF:updatefield ( ent / cmd rtn )
  301.     (setq cmd (getvar 'cmdecho))
  302.     (setvar 'cmdecho 0)
  303.     (setq rtn (vl-cmdf "_.updatefield" ent ""))
  304.     (setvar 'cmdecho cmd)
  305.     rtn
  306. )
  307. ;; ssget  -  Lee Mac
  308. ;; A wrapper for the ssget function to permit the use of a custom selection prompt
  309. ;; msg - [str] selection prompt
  310. ;; arg - [lst] list of ssget arguments
  311. (defun LM:ssget ( msg arg / sel )
  312.     (princ msg)
  313.     (setvar 'nomutt 1)
  314.     (setq sel (vl-catch-all-apply 'ssget arg))
  315.     (setvar 'nomutt 0)
  316.     (if (not (vl-catch-all-error-p sel)) sel)
  317. )
  318. ;; Get MLeader Attributes  -  Lee Mac
  319. ;; Returns an association list of attribute tags & object IDs for all attributes held by an mleader block
  320. ;; mld - [vla] MLeader vla-object
  321. ;; Returns: [lst] List of ((<Attribute Tag> . <Object ID>) ... )
  322. (defun LM:getmleaderattributes ( mld / rtn )
  323.     (vlax-for obj (vla-item (vla-get-blocks (vla-get-document mld)) (vla-get-contentblockname mld))
  324.         (if
  325.             (and
  326.                 (= "AcDbAttributeDefinition" (vla-get-objectname obj))
  327.                 (= :vlax-false (vla-get-constant obj))
  328.             )
  329.             (setq rtn (cons (cons (strcase (vla-get-tagstring obj)) (LM:intobjectid obj)) rtn))
  330.         )
  331.     )
  332.     (reverse rtn)
  333. )
  334. ;; Object ID (integer)  -  Lee Mac
  335. ;; Returns an integer representing the ObjectID of a supplied VLA-Object
  336. ;; Compatible with 32-bit & 64-bit systems
  337. (defun LM:intobjectid ( obj )
  338.     (if (vlax-property-available-p obj 'objectid32)
  339.         (defun LM:intobjectid ( obj ) (vla-get-objectid32 obj))
  340.         (defun LM:intobjectid ( obj ) (vla-get-objectid   obj))
  341.     )
  342.     (LM:intobjectid obj)
  343. )
  344. ;; Set MLeader Attribute Value  -  Lee Mac
  345. ;; obj - [vla] MLeader vla-object
  346. ;; idx - [int] Attribute Definition Object ID
  347. ;; str - [str] Attribute value
  348. (defun LM:setmleaderattributevalue ( obj idx str )
  349.     (if (vlax-method-applicable-p obj 'setblockattributevalue32)
  350.         (defun LM:setmleaderattributevalue ( obj idx str ) (vla-setblockattributevalue32 obj idx str))
  351.         (defun LM:setmleaderattributevalue ( obj idx str ) (vla-setblockattributevalue   obj idx str))
  352.     )
  353.     (LM:setmleaderattributevalue obj idx str)
  354. )
  355. ;; List Box  -  Lee Mac
  356. ;; Displays a DCL list box allowing the user to make a selection from the supplied data.
  357. ;; msg - [str] Dialog label
  358. ;; lst - [lst] List of strings to display
  359. ;; bit - [int] 1=allow multiple; 2=return indexes
  360. ;; Returns: [lst] List of selected items/indexes, else nil
  361. (defun LM:listbox ( msg lst bit / dch des tmp rtn )
  362.     (cond
  363.         (   (not
  364.                 (and
  365.                     (setq tmp (vl-filename-mktemp nil nil ".dcl"))
  366.                     (setq des (open tmp "w"))
  367.                     (write-line
  368.                         (strcat "listbox:dialog{label="" msg "";spacer;:list_box{key="list";multiple_select="
  369.                             (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}"
  370.                         )
  371.                         des
  372.                     )
  373.                     (not (close des))
  374.                     (< 0 (setq dch (load_dialog tmp)))
  375.                     (new_dialog "listbox" dch)
  376.                 )
  377.             )
  378.             (prompt "\nError Loading List Box Dialog.")
  379.         )
  380.         (   t     
  381.             (start_list "list")
  382.             (foreach itm lst (add_list itm))
  383.             (end_list)
  384.             (setq rtn (set_tile "list" "0"))
  385.             (action_tile "list" "(setq rtn $value)")
  386.             (setq rtn
  387.                 (if (= 1 (start_dialog))
  388.                     (if (= 2 (logand 2 bit))
  389.                         (read (strcat "(" rtn ")"))
  390.                         (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
  391.                     )
  392.                 )
  393.             )
  394.         )
  395.     )
  396.     (if (< 0 dch)
  397.         (unload_dialog dch)
  398.     )
  399.     (if (and tmp (setq tmp (findfile tmp)))
  400.         (vl-file-delete tmp)
  401.     )
  402.     rtn
  403. )
  404. ;; Get Cell  -  Lee Mac
  405. ;; If the supplied point lies within a cell boundary,
  406. ;; returns a list of: (<VLA Table Object> <Row> <Col>)
  407. (defun LM:getcell ( lst pnt / dir )
  408.     (setq dir (vlax-3D-point (trans (getvar 'viewdir) 1 0))
  409.           pnt (vlax-3D-point pnt)
  410.     )
  411.     (vl-some
  412.        '(lambda ( tab / row col )
  413.             (if (= :vlax-true (vla-hittest tab pnt dir 'row 'col))
  414.                 (list tab row col)
  415.             )
  416.         )
  417.         lst
  418.     )
  419. )
  420. ;; ObjectID  -  Lee Mac
  421. ;; Returns a string containing the ObjectID of a supplied VLA-Object
  422. ;; Compatible with 32-bit & 64-bit systems
  423. (defun LM:objectid ( obj )
  424.     (eval
  425.         (list 'defun 'LM:objectid '( obj )
  426.             (if (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
  427.                 (if (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
  428.                     (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
  429.                    '(LM:ename->objectid (vlax-vla-object->ename obj))
  430.                 )
  431.                '(itoa (vla-get-objectid obj))
  432.             )
  433.         )
  434.     )
  435.     (LM:objectid obj)
  436. )
  437. ;; Entity Name to ObjectID  -  Lee Mac
  438. ;; Returns the 32-bit or 64-bit ObjectID for a supplied entity name
  439. (defun LM:ename->objectid ( ent )
  440.     (LM:hex->decstr
  441.         (setq ent (vl-string-right-trim ">" (vl-prin1-to-string ent))
  442.               ent (substr ent (+ (vl-string-position 58 ent) 3))
  443.         )
  444.     )
  445. )
  446. ;; Hex to Decimal String  -  Lee Mac
  447. ;; Returns the decimal representation of a supplied hexadecimal string
  448. (defun LM:hex->decstr ( hex / foo bar )
  449.     (defun foo ( lst rtn )
  450.         (if lst
  451.             (foo (cdr lst) (bar (- (car lst) (if (< 57 (car lst)) 55 48)) rtn))
  452.             (apply 'strcat (mapcar 'itoa (reverse rtn)))
  453.         )
  454.     )
  455.     (defun bar ( int lst )
  456.         (if lst
  457.             (if (or (< 0 (setq int (+ (* 16 (car lst)) int))) (cdr lst))
  458.                 (cons (rem int 10) (bar (/ int 10) (cdr lst)))
  459.             )
  460.             (bar int '(0))
  461.         )
  462.     )
  463.     (foo (vl-string->list (strcase hex)) nil)
  464. )
  465. ;; Start Undo  -  Lee Mac
  466. ;; Opens an Undo Group.
  467. (defun LM:startundo ( doc )
  468.     (LM:endundo doc)
  469.     (vla-startundomark doc)
  470. )
  471. ;; End Undo  -  Lee Mac
  472. ;; Closes an Undo Group.
  473. (defun LM:endundo ( doc )
  474.     (while (= 8 (logand 8 (getvar 'undoctl)))
  475.         (vla-endundomark doc)
  476.     )
  477. )
  478. ;; Active Document  -  Lee Mac
  479. ;; Returns the VLA Active Document Object
  480. (defun LM:acdoc nil
  481.     (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
  482.     (LM:acdoc)
  483. )
  484. ;;----------------------------------------------------------------------;;
  485. (vl-load-com)
  486. (princ
  487.     (strcat
  488.         "\n:: LengthField.lsp | Version 1.0 | \\U+00A9 Lee Mac "
  489.         (menucmd "m=$(edtime,0,yyyy)")
  490.         " www.lee-mac.com ::"
  491.         "\n:: Type "LF" to Invoke ::"
  492.     )
  493. )
  494. (princ)
  495. ;;----------------------------------------------------------------------;;
  496. ;;                             End of File                              ;;
  497. ;;----------------------------------------------------------------------;;

 
141034b1t4tkuuyyuwdvk6.png
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 13:17:49 | 显示全部楼层
如果你看这一行(setq fmt“L*=%lu6%pr2 cm”),它保持格式,而不测试lu6长度单位6=“当前单位”,精度2小数需要更改单位或将长度除以100,即为米。因此,如果m或Cm,则将fmt设置为适合。如果执行多行文字选择字段,则拾取一个对象,您可以看到文字发生变化
回复

使用道具 举报

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 13:20:57 | 显示全部楼层
如何做“如果”的事情
我是新手。
 
回复

使用道具 举报

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 13:26:06 | 显示全部楼层
有人能给我指路吗?
有任何教程如何做这种“如果”
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 13:29:43 | 显示全部楼层
下载我原来的长度场程序。
 
更换线路63-65:
  1.     (setq fmt "%lu6" ;; Field Formatting
  2.           tag nil    ;; Optional predefined attribute tag
  3.     )
  1.     (
  2.         (lambda ( / tmp )
  3.             (if (null lf:inc) (setq lf:inc 1) (setq lf:inc (1+ lf:inc)))
  4.             (if (null lf:unt) (setq lf:unt "Meters"))
  5.             (initget 6)
  6.             (if (setq tmp (getint (strcat "\nSpecify length ID <" (itoa lf:inc) ">: ")))
  7.                 (setq lf:inc tmp)
  8.             )
  9.             (initget "Meters Centimeters")
  10.             (if (setq tmp (getkword (strcat "\nSpecify units [Meters/Centimeters] <" lf:unt ">: ")))
  11.                 (setq lf:unt tmp)
  12.             )
  13.             (setq fmt (strcat "%lu6%ps[L" (itoa lf:inc) "=," (if (= lf:unt "Meters") "m]%ct8[0.01]" "cm]")))
  14.         )
  15.     )
回复

使用道具 举报

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 13:37:58 | 显示全部楼层
谢谢李。我喜欢你的Lisp程序!
我想知道你一半的编程知识。
 
为想要的人提供完整的代码:
  1. (defun increment (str / )
  2. (if (= mynumber nil) (setq mynumber 0))
  3. (setq mynumber (+ mynumber 1))
  4. (princ "\Current Number :<")(princ mynumber)
  5.         (setq askw (getint "> : "))
  6.         (if (/= askw nil)(setq mynumber askw))
  7.         (vl-string-subst (itoa mynumber) "*" str)
  8. )
  9. ;;-------------------------=={ Length Field }==-------------------------;;
  10. ;;                                                                      ;;
  11. ;;  This program allows a user to generate a field expression           ;;
  12. ;;  referencing the length/perimeter/circumference of one or more       ;;
  13. ;;  selected objects. In the case of selecting multiple objects, the    ;;
  14. ;;  field expression will reference the sum of the lengths of all       ;;
  15. ;;  objects in the selection.                                           ;;
  16. ;;                                                                      ;;
  17. ;;  The user may opt to specify a point at which to create a new        ;;
  18. ;;  multiline text object housing the field expression, pick a table    ;;
  19. ;;  cell in which the field should be inserted, or select an existing   ;;
  20. ;;  single-line text, multiline text, multileader, or attribute to      ;;
  21. ;;  be populated with the field expression.                             ;;
  22. ;;                                                                      ;;
  23. ;;  Upon issuing the command syntax 'LF' (Length Field) at the AutoCAD  ;;
  24. ;;  command-line, the program first prompts the user to make a          ;;
  25. ;;  selection of objects for which to return the length summation.      ;;
  26. ;;                                                                      ;;
  27. ;;  At this prompt, the user may select any number of Arcs, Circles,    ;;
  28. ;;  Lines, 2D Polylines (light or heavy), or 3D Polylines.              ;;
  29. ;;                                                                      ;;
  30. ;;  The user is then prompted to specify a point or table cell to       ;;
  31. ;;  insert a field expression referencing the summation of the lengths  ;;
  32. ;;  of the selected objects.                                            ;;
  33. ;;                                                                      ;;
  34. ;;  At this prompt, the user may also choose the 'Object' option in     ;;
  35. ;;  order to populate the content of an existing annotation object      ;;
  36. ;;  with the field expression.                                          ;;
  37. ;;                                                                      ;;
  38. ;;  Upon choosing this option, the user may select any single-line      ;;
  39. ;;  text (DText), multiline text (MText), single-line or multiline      ;;
  40. ;;  attribute, attributed block, or multileader (MLeader) with either   ;;
  41. ;;  multiline text or attributed block content.                         ;;
  42. ;;                                                                      ;;
  43. ;;  If the user selects an attributed block or attributed multileader   ;;
  44. ;;  with more than one attribute, the user is presented with a dialog   ;;
  45. ;;  interface listing the available attributes, and is prompted to      ;;
  46. ;;  select a destination for the field expression.                      ;;
  47. ;;                                                                      ;;
  48. ;;  The user may optionally predefine the target block/multileader      ;;
  49. ;;  attribute by specifying the attribute tag where noted at the top    ;;
  50. ;;  of the program source code.                                         ;;
  51. ;;                                                                      ;;
  52. ;;  The resulting field expression will display the sum of the lengths  ;;
  53. ;;  of the selected objects, formatted using the field formatting code  ;;
  54. ;;  specified at the top of the program.                                ;;
  55. ;;                                                                      ;;
  56. ;;----------------------------------------------------------------------;;
  57. ;;  Author:  Lee Mac, Copyright © 2017  -  www.lee-mac.com              ;;
  58. ;;----------------------------------------------------------------------;;
  59. ;;  Version 1.0    -    2017-08-06                                      ;;
  60. ;;                                                                      ;;
  61. ;;  - First release.                                                    ;;
  62. ;;----------------------------------------------------------------------;;
  63. ;;  Version 1.1    -    2017-08-06                                      ;;
  64. ;;                                                                      ;;
  65. ;;  - Program modified to account for selection of existing annotation  ;;
  66. ;;    objects which already contain a field expression.                 ;;
  67. ;;----------------------------------------------------------------------;;
  68. (defun c:lf ( / *error* ent enx flg fmt idx lst obj oid prp sel str tab tag tmp typ )
  69. ;if
  70. (princ "\nEnter an option [Meter/Cm] <Unit>: ")
  71.     (setq fmt "%lu6?") ;; Field Formatting
  72.     (setq
  73.           fmt (increment fmt)
  74.           tag nil    ;; Optional predefined attribute tag
  75.     )
  76.    
  77. ;;************************************************************************;;
  78. (
  79.         (lambda ( / tmp )
  80.             (if (null lf:inc) (setq lf:inc 1) (setq lf:inc (1+ lf:inc)))
  81.             (if (null lf:unt) (setq lf:unt "Meters"))
  82.             (initget 6)
  83.             (if (setq tmp (getint (strcat "\nSpecify length ID <" (itoa lf:inc) ">: ")))
  84.                 (setq lf:inc tmp)
  85.             )
  86.             (initget "Meters Centimeters")
  87.             (if (setq tmp (getkword (strcat "\nSpecify units [Meters/Centimeters] <" lf:unt ">: ")))
  88.                 (setq lf:unt tmp)
  89.             )
  90.             (setq fmt (strcat "%lu6%ps[L" (itoa lf:inc) "=," (if (= lf:unt "Meters") "m]%ct8[0.01]" "cm]")))
  91.         )
  92.     )
  93. ;;***************************************************************************;;
  94.     (defun *error* ( msg )
  95.         (LM:endundo (LM:acdoc))
  96.         (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
  97.             (princ (strcat "\nError: " msg))
  98.         )
  99.         (princ)
  100.     )
  101.     (LM:startundo (LM:acdoc))
  102.     (setq prp
  103.        '(
  104.             ("AcDbArc"        . "ArcLength")
  105.             ("AcDbCircle"     . "Circumference")
  106.             ("AcDbLine"       . "Length")
  107.             ("AcDbPolyline"   . "Length")
  108.             ("AcDb2dPolyline" . "Length")
  109.             ("AcDb3dPolyline" . "Length")
  110.         )
  111.     )
  112.     (if
  113.         (setq sel
  114.             (LM:ssget "\nSelect objects to obtain total length <exit>: "
  115.                 (list
  116.                     (list
  117.                        '(000 . "ARC,CIRCLE,LINE,*POLYLINE")
  118.                        '(-04 . "<NOT")
  119.                            '(-04 . "<AND")
  120.                                '(000 . "POLYLINE") '(-04 . "&") '(070 . 80)
  121.                            '(-04 . "AND>")
  122.                        '(-04 . "NOT>")
  123.                         (if (= 1 (getvar 'cvport))
  124.                             (cons 410 (getvar 'ctab))
  125.                            '(410 . "Model")
  126.                         )
  127.                     )
  128.                 )
  129.             )
  130.         )
  131.         (progn
  132.             (if (= 1 (sslength sel))
  133.                 (setq obj (vlax-ename->vla-object (ssname sel 0))
  134.                       str
  135.                     (strcat
  136.                         "%<\\AcObjProp Object(%<\\_ObjId "
  137.                         (LM:objectid obj)
  138.                         ">%)." (cdr (assoc (vla-get-objectname obj) prp)) " \\f "" fmt "">%"
  139.                     )
  140.                 )
  141.                 (progn
  142.                     (repeat (setq idx (sslength sel))
  143.                         (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))
  144.                               lst
  145.                             (vl-list*
  146.                                 "%<\\AcObjProp Object(%<\\_ObjId "
  147.                                 (LM:objectid obj)
  148.                                 ">%)." (cdr (assoc (vla-get-objectname obj) prp)) ">%" " + "
  149.                                 lst
  150.                             )
  151.                         )
  152.                     )
  153.                     (setq str
  154.                         (strcat
  155.                             "%<\\AcExpr "
  156.                             (apply 'strcat (reverse (cdr (reverse lst))))
  157.                             " \\f "" fmt "">%"
  158.                         )
  159.                     )
  160.                 )
  161.             )
  162.             (if
  163.                 (setq tmp
  164.                     (ssget "_X"
  165.                         (list '(0 . "ACAD_TABLE")
  166.                             (if (= 1 (getvar 'cvport))
  167.                                 (cons 410 (getvar 'ctab))
  168.                                '(410 . "Model")
  169.                             )
  170.                         )
  171.                     )
  172.                 )
  173.                 (repeat (setq idx (sslength tmp))
  174.                     (setq tab (cons (vlax-ename->vla-object (ssname tmp (setq idx (1- idx)))) tab))
  175.                 )
  176.             )
  177.             (while
  178.                 (not
  179.                     (progn
  180.                         (if flg
  181.                             (progn
  182.                                 (setvar 'errno 0)
  183.                                 (initget "Point eXit")
  184.                                 (setq sel (nentsel "\nSelect text, mtext, mleader, attribute or attributed block [Point/eXit] <eXit>: "))
  185.                             )
  186.                             (progn
  187.                                 (initget "Object eXit")
  188.                                 (setq sel (getpoint "\nSpecify point or cell for field [Object/eXit] <eXit>: "))
  189.                             )
  190.                         )
  191.                         (cond
  192.                             (   (= 7 (getvar 'errno))
  193.                                 (prompt "\nMissed, try again.")
  194.                             )
  195.                             (   (or (null sel) (= "eXit" sel)))
  196.                             (   (= "Point" sel)
  197.                                 (setq flg nil)
  198.                             )
  199.                             (   (= "Object" sel)
  200.                                 (not (setq flg t))
  201.                             )
  202.                             (   flg
  203.                                 (setq ent (car sel)
  204.                                       enx (entget ent)
  205.                                       typ (cdr (assoc 0 enx))
  206.                                       obj (vlax-ename->vla-object ent)
  207.                                 )
  208.                                 (cond
  209.                                     (   (and (= 2 (length sel)) (wcmatch typ "TEXT,MTEXT"))
  210.                                         (if (vlax-write-enabled-p obj)
  211.                                             (LF:puttextstring obj str)
  212.                                             (prompt "\nThe selected text object is on a locked layer.")
  213.                                         )
  214.                                     )
  215.                                     (   (and (= "ATTRIB" typ)
  216.                                              (/= 'str (type tag))
  217.                                         )
  218.                                         (if (vlax-write-enabled-p obj)
  219.                                             (progn
  220.                                                 (LF:puttextstring obj str)
  221.                                                 (LF:updatefield ent)
  222.                                             )
  223.                                             (prompt "\nThe selected attribute is on a locked layer.")
  224.                                         )
  225.                                     )
  226.                                     (   (and
  227.                                             (or
  228.                                                 (and (= "ATTRIB" typ)
  229.                                                      (setq tmp (cdr (assoc 330 enx)))
  230.                                                 )
  231.                                                 (and (setq tmp (last (cadddr sel)))
  232.                                                      (= "INSERT" (cdr (assoc 0 (entget tmp))))
  233.                                                 )
  234.                                             )
  235.                                             (setq tmp (vlax-invoke (vlax-ename->vla-object tmp) 'getattributes))
  236.                                             (or
  237.                                                 (and (= 'str (type tag))
  238.                                                      (setq idx (vl-position (strcase tag) (mapcar 'vla-get-tagstring tmp)))
  239.                                                      (setq obj (nth idx tmp))
  240.                                                 )
  241.                                                 (and (not (cdr tmp))
  242.                                                      (setq obj (car tmp))
  243.                                                 )
  244.                                                 (and (setq idx (LM:listbox "Choose Attribute" (mapcar 'vla-get-tagstring tmp) 2))
  245.                                                      (setq obj (nth (car idx) tmp))
  246.                                                 )
  247.                                             )
  248.                                         )
  249.                                         (if (vlax-write-enabled-p obj)
  250.                                             (progn
  251.                                                 (LF:puttextstring obj str)
  252.                                                 (LF:updatefield (vlax-vla-object->ename obj))
  253.                                             )
  254.                                             (prompt "\nThe selected attribute is on a locked layer.")
  255.                                         )
  256.                                     )
  257.                                     (   (and (= 2 (length sel)) (= "MULTILEADER" typ))
  258.                                         (setq typ (cdr (assoc 172 (reverse enx))))
  259.                                         (cond
  260.                                             (   (and (<= acblockcontent typ acmtextcontent) (not (vlax-write-enabled-p obj)))
  261.                                                 (prompt "\nThe selected multileader is on a locked layer.")
  262.                                             )
  263.                                             (   (= acmtextcontent typ)
  264.                                                 (LF:puttextstring obj str)
  265.                                                 (vla-regen (LM:acdoc) acactiveviewport)
  266.                                                 t
  267.                                             )
  268.                                             (   (and
  269.                                                     (= acblockcontent typ)
  270.                                                     (setq tmp (LM:getmleaderattributes obj))
  271.                                                     (or
  272.                                                         (and (= 'str (type tag))
  273.                                                              (setq oid (cdr (assoc (strcase tag) tmp)))
  274.                                                         )
  275.                                                         (and (not (cdr tmp))
  276.                                                              (setq oid (cdar tmp))
  277.                                                         )
  278.                                                         (and (setq idx (LM:listbox "Choose Attribute" (mapcar 'car tmp) 2))
  279.                                                              (setq oid (cdr (nth (car idx) tmp)))
  280.                                                         )
  281.                                                     )
  282.                                                 )
  283.                                                 (LM:setmleaderattributevalue obj oid str)
  284.                                                 (vla-regen (LM:acdoc) acactiveviewport)
  285.                                                 t
  286.                                             )
  287.                                             (   (prompt "\nThe select multileader has no editable content."))
  288.                                         )
  289.                                     )
  290.                                     (   (prompt "\nThe selected object is not text, mtext, multileader, attribute or attributed block."))
  291.                                 )
  292.                             )
  293.                             (   (setq tmp (LM:getcell tab (trans sel 1 0)))
  294.                                 (if (vlax-write-enabled-p (car tmp))
  295.                                     (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-settext (append tmp (list str)))))
  296.                                     (prompt "\nThe selected table cell belongs to a table on a locked layer.")
  297.                                 )
  298.                             )
  299.                             (   (vla-addmtext
  300.                                     (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace))
  301.                                     (vlax-3D-point (trans sel 1 0))
  302.                                     0.0
  303.                                     str
  304.                                 )
  305.                             )
  306.                         )
  307.                     )
  308.                 )
  309.             )
  310.         )
  311.     )
  312.     (*error* nil) (princ)
  313. )
  314. (defun LF:puttextstring ( obj str )
  315.     (vla-put-textstring obj "") ;; To clear any existing field
  316.     (vla-put-textstring obj str)
  317.     t
  318. )
  319. (defun LF:updatefield ( ent / cmd rtn )
  320.     (setq cmd (getvar 'cmdecho))
  321.     (setvar 'cmdecho 0)
  322.     (setq rtn (vl-cmdf "_.updatefield" ent ""))
  323.     (setvar 'cmdecho cmd)
  324.     rtn
  325. )
  326. ;; ssget  -  Lee Mac
  327. ;; A wrapper for the ssget function to permit the use of a custom selection prompt
  328. ;; msg - [str] selection prompt
  329. ;; arg - [lst] list of ssget arguments
  330. (defun LM:ssget ( msg arg / sel )
  331.     (princ msg)
  332.     (setvar 'nomutt 1)
  333.     (setq sel (vl-catch-all-apply 'ssget arg))
  334.     (setvar 'nomutt 0)
  335.     (if (not (vl-catch-all-error-p sel)) sel)
  336. )
  337. ;; Get MLeader Attributes  -  Lee Mac
  338. ;; Returns an association list of attribute tags & object IDs for all attributes held by an mleader block
  339. ;; mld - [vla] MLeader vla-object
  340. ;; Returns: [lst] List of ((<Attribute Tag> . <Object ID>) ... )
  341. (defun LM:getmleaderattributes ( mld / rtn )
  342.     (vlax-for obj (vla-item (vla-get-blocks (vla-get-document mld)) (vla-get-contentblockname mld))
  343.         (if
  344.             (and
  345.                 (= "AcDbAttributeDefinition" (vla-get-objectname obj))
  346.                 (= :vlax-false (vla-get-constant obj))
  347.             )
  348.             (setq rtn (cons (cons (strcase (vla-get-tagstring obj)) (LM:intobjectid obj)) rtn))
  349.         )
  350.     )
  351.     (reverse rtn)
  352. )
  353. ;; Object ID (integer)  -  Lee Mac
  354. ;; Returns an integer representing the ObjectID of a supplied VLA-Object
  355. ;; Compatible with 32-bit & 64-bit systems
  356. (defun LM:intobjectid ( obj )
  357.     (if (vlax-property-available-p obj 'objectid32)
  358.         (defun LM:intobjectid ( obj ) (vla-get-objectid32 obj))
  359.         (defun LM:intobjectid ( obj ) (vla-get-objectid   obj))
  360.     )
  361.     (LM:intobjectid obj)
  362. )
  363. ;; Set MLeader Attribute Value  -  Lee Mac
  364. ;; obj - [vla] MLeader vla-object
  365. ;; idx - [int] Attribute Definition Object ID
  366. ;; str - [str] Attribute value
  367. (defun LM:setmleaderattributevalue ( obj idx str )
  368.     (if (vlax-method-applicable-p obj 'setblockattributevalue32)
  369.         (defun LM:setmleaderattributevalue ( obj idx str ) (vla-setblockattributevalue32 obj idx str))
  370.         (defun LM:setmleaderattributevalue ( obj idx str ) (vla-setblockattributevalue   obj idx str))
  371.     )
  372.     (LM:setmleaderattributevalue obj idx str)
  373. )
  374. ;; List Box  -  Lee Mac
  375. ;; Displays a DCL list box allowing the user to make a selection from the supplied data.
  376. ;; msg - [str] Dialog label
  377. ;; lst - [lst] List of strings to display
  378. ;; bit - [int] 1=allow multiple; 2=return indexes
  379. ;; Returns: [lst] List of selected items/indexes, else nil
  380. (defun LM:listbox ( msg lst bit / dch des tmp rtn )
  381.     (cond
  382.         (   (not
  383.                 (and
  384.                     (setq tmp (vl-filename-mktemp nil nil ".dcl"))
  385.                     (setq des (open tmp "w"))
  386.                     (write-line
  387.                         (strcat "listbox:dialog{label="" msg "";spacer;:list_box{key="list";multiple_select="
  388.                             (if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=15;}spacer;ok_cancel;}"
  389.                         )
  390.                         des
  391.                     )
  392.                     (not (close des))
  393.                     (< 0 (setq dch (load_dialog tmp)))
  394.                     (new_dialog "listbox" dch)
  395.                 )
  396.             )
  397.             (prompt "\nError Loading List Box Dialog.")
  398.         )
  399.         (   t     
  400.             (start_list "list")
  401.             (foreach itm lst (add_list itm))
  402.             (end_list)
  403.             (setq rtn (set_tile "list" "0"))
  404.             (action_tile "list" "(setq rtn $value)")
  405.             (setq rtn
  406.                 (if (= 1 (start_dialog))
  407.                     (if (= 2 (logand 2 bit))
  408.                         (read (strcat "(" rtn ")"))
  409.                         (mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
  410.                     )
  411.                 )
  412.             )
  413.         )
  414.     )
  415.     (if (< 0 dch)
  416.         (unload_dialog dch)
  417.     )
  418.     (if (and tmp (setq tmp (findfile tmp)))
  419.         (vl-file-delete tmp)
  420.     )
  421.     rtn
  422. )
  423. ;; Get Cell  -  Lee Mac
  424. ;; If the supplied point lies within a cell boundary,
  425. ;; returns a list of: (<VLA Table Object> <Row> <Col>)
  426. (defun LM:getcell ( lst pnt / dir )
  427.     (setq dir (vlax-3D-point (trans (getvar 'viewdir) 1 0))
  428.           pnt (vlax-3D-point pnt)
  429.     )
  430.     (vl-some
  431.        '(lambda ( tab / row col )
  432.             (if (= :vlax-true (vla-hittest tab pnt dir 'row 'col))
  433.                 (list tab row col)
  434.             )
  435.         )
  436.         lst
  437.     )
  438. )
  439. ;; ObjectID  -  Lee Mac
  440. ;; Returns a string containing the ObjectID of a supplied VLA-Object
  441. ;; Compatible with 32-bit & 64-bit systems
  442. (defun LM:objectid ( obj )
  443.     (eval
  444.         (list 'defun 'LM:objectid '( obj )
  445.             (if (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
  446.                 (if (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring)
  447.                     (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false)
  448.                    '(LM:ename->objectid (vlax-vla-object->ename obj))
  449.                 )
  450.                '(itoa (vla-get-objectid obj))
  451.             )
  452.         )
  453.     )
  454.     (LM:objectid obj)
  455. )
  456. ;; Entity Name to ObjectID  -  Lee Mac
  457. ;; Returns the 32-bit or 64-bit ObjectID for a supplied entity name
  458. (defun LM:ename->objectid ( ent )
  459.     (LM:hex->decstr
  460.         (setq ent (vl-string-right-trim ">" (vl-prin1-to-string ent))
  461.               ent (substr ent (+ (vl-string-position 58 ent) 3))
  462.         )
  463.     )
  464. )
  465. ;; Hex to Decimal String  -  Lee Mac
  466. ;; Returns the decimal representation of a supplied hexadecimal string
  467. (defun LM:hex->decstr ( hex / foo bar )
  468.     (defun foo ( lst rtn )
  469.         (if lst
  470.             (foo (cdr lst) (bar (- (car lst) (if (< 57 (car lst)) 55 48)) rtn))
  471.             (apply 'strcat (mapcar 'itoa (reverse rtn)))
  472.         )
  473.     )
  474.     (defun bar ( int lst )
  475.         (if lst
  476.             (if (or (< 0 (setq int (+ (* 16 (car lst)) int))) (cdr lst))
  477.                 (cons (rem int 10) (bar (/ int 10) (cdr lst)))
  478.             )
  479.             (bar int '(0))
  480.         )
  481.     )
  482.     (foo (vl-string->list (strcase hex)) nil)
  483. )
  484. ;; Start Undo  -  Lee Mac
  485. ;; Opens an Undo Group.
  486. (defun LM:startundo ( doc )
  487.     (LM:endundo doc)
  488.     (vla-startundomark doc)
  489. )
  490. ;; End Undo  -  Lee Mac
  491. ;; Closes an Undo Group.
  492. (defun LM:endundo ( doc )
  493.     (while (= 8 (logand 8 (getvar 'undoctl)))
  494.         (vla-endundomark doc)
  495.     )
  496. )
  497. ;; Active Document  -  Lee Mac
  498. ;; Returns the VLA Active Document Object
  499. (defun LM:acdoc nil
  500.     (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
  501.     (LM:acdoc)
  502. )
  503. ;;----------------------------------------------------------------------;;
  504. (vl-load-com)
  505. (princ
  506.     (strcat
  507.         "\n:: LengthField.lsp | Version 1.0 | \\U+00A9 Lee Mac "
  508.         (menucmd "m=$(edtime,0,yyyy)")
  509.         " www.lee-mac.com ::"
  510.         "\n:: Type "LF" to Invoke ::"
  511.     )
  512. )
  513. (princ)
  514. ;;----------------------------------------------------------------------;;
  515. ;;                             End of File                              ;;
  516. ;;----------------------------------------------------------------------;;
回复

使用道具 举报

66

主题

1552

帖子

1514

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
325
发表于 2022-7-5 13:40:01 | 显示全部楼层
 
问题是,你不知道他一半的知识是多少! 
回复

使用道具 举报

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 13:44:40 | 显示全部楼层
绝对比我所知道的要多
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-5 13:47:39 | 显示全部楼层
 
不客气。
 
请注意,我建议的修改应该在我的原始程序中实现,而不是在您的修改版本中实现。
回复

使用道具 举报

5

主题

24

帖子

19

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 13:55:40 | 显示全部楼层
我注意到了,但我仍然想要修改。有一种方法可以毫无问题地做到这一点。
因为知道它使结果除以100
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-15 00:49 , Processed in 3.692783 second(s), 75 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表