我有一个Lisp程序的Lisp程序,告诉我线的长度。
但它只在厘米中显示。
我希望它会问我是用米还是厘米表示。
类似这样的选项可供选择
我希望你能帮我
- (defun increment (str / )
- (if (= mynumber nil) (setq mynumber 0))
- (setq mynumber (+ mynumber 1))
- (princ "\Current Number :<")(princ mynumber)
- (setq askw (getint "> : "))
- (if (/= askw nil)(setq mynumber askw))
- (vl-string-subst (itoa mynumber) "*" str)
- )
- ;;-------------------------=={ Length Field }==-------------------------;;
- ;; ;;
- ;; This program allows a user to generate a field expression ;;
- ;; referencing the length/perimeter/circumference of one or more ;;
- ;; selected objects. In the case of selecting multiple objects, the ;;
- ;; field expression will reference the sum of the lengths of all ;;
- ;; objects in the selection. ;;
- ;; ;;
- ;; The user may opt to specify a point at which to create a new ;;
- ;; multiline text object housing the field expression, pick a table ;;
- ;; cell in which the field should be inserted, or select an existing ;;
- ;; single-line text, multiline text, multileader, or attribute to ;;
- ;; be populated with the field expression. ;;
- ;; ;;
- ;; Upon issuing the command syntax 'LF' (Length Field) at the AutoCAD ;;
- ;; command-line, the program first prompts the user to make a ;;
- ;; selection of objects for which to return the length summation. ;;
- ;; ;;
- ;; At this prompt, the user may select any number of Arcs, Circles, ;;
- ;; Lines, 2D Polylines (light or heavy), or 3D Polylines. ;;
- ;; ;;
- ;; The user is then prompted to specify a point or table cell to ;;
- ;; insert a field expression referencing the summation of the lengths ;;
- ;; of the selected objects. ;;
- ;; ;;
- ;; At this prompt, the user may also choose the 'Object' option in ;;
- ;; order to populate the content of an existing annotation object ;;
- ;; with the field expression. ;;
- ;; ;;
- ;; Upon choosing this option, the user may select any single-line ;;
- ;; text (DText), multiline text (MText), single-line or multiline ;;
- ;; attribute, attributed block, or multileader (MLeader) with either ;;
- ;; multiline text or attributed block content. ;;
- ;; ;;
- ;; If the user selects an attributed block or attributed multileader ;;
- ;; with more than one attribute, the user is presented with a dialog ;;
- ;; interface listing the available attributes, and is prompted to ;;
- ;; select a destination for the field expression. ;;
- ;; ;;
- ;; The user may optionally predefine the target block/multileader ;;
- ;; attribute by specifying the attribute tag where noted at the top ;;
- ;; of the program source code. ;;
- ;; ;;
- ;; The resulting field expression will display the sum of the lengths ;;
- ;; of the selected objects, formatted using the field formatting code ;;
- ;; specified at the top of the program. ;;
- ;; ;;
- ;;----------------------------------------------------------------------;;
- ;; Author: Lee Mac, Copyright © 2017 - www.lee-mac.com ;;
- ;;----------------------------------------------------------------------;;
- ;; Version 1.0 - 2017-08-06 ;;
- ;; ;;
- ;; - First release. ;;
- ;;----------------------------------------------------------------------;;
- ;; Version 1.1 - 2017-08-06 ;;
- ;; ;;
- ;; - Program modified to account for selection of existing annotation ;;
- ;; objects which already contain a field expression. ;;
- ;;----------------------------------------------------------------------;;
- (defun c:lf ( / *error* ent enx flg fmt idx lst obj oid prp sel str tab tag tmp typ )
- (setq fmt "L*=%lu6%pr2 cm") ;; Field Formatting
- (setq
- fmt (increment fmt)
- tag nil ;; Optional predefined attribute tag
- )
-
- (defun *error* ( msg )
- (LM:endundo (LM:acdoc))
- (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
- (princ (strcat "\nError: " msg))
- )
- (princ)
- )
- (LM:startundo (LM:acdoc))
- (setq prp
- '(
- ("AcDbArc" . "ArcLength")
- ("AcDbCircle" . "Circumference")
- ("AcDbLine" . "Length")
- ("AcDbPolyline" . "Length")
- ("AcDb2dPolyline" . "Length")
- ("AcDb3dPolyline" . "Length")
- )
- )
- (if
- (setq sel
- (LM:ssget "\nSelect objects to obtain total length <exit>: "
- (list
- (list
- '(000 . "ARC,CIRCLE,LINE,*POLYLINE")
- '(-04 . "<NOT")
- '(-04 . "<AND")
- '(000 . "POLYLINE") '(-04 . "&") '(070 . 80)
- '(-04 . "AND>")
- '(-04 . "NOT>")
- (if (= 1 (getvar 'cvport))
- (cons 410 (getvar 'ctab))
- '(410 . "Model")
- )
- )
- )
- )
- )
|