我有一个lisp,来自Kent Cooper,大约2010年,在每一条相交的直线上输入一个维度。它似乎仅限于在什么样的物体上断裂。我公司的CAD有他们合并的自定义对象,lisp无法将其识别为对象。有谁能稍微改变一下,给所有物体标注尺寸?非常感谢。
- ;; QuickDimAligned.lsp [command name: QDA]
- ;; To make a collinear series of Aligned Dimensions along
- ;; a single fence line, between all intersections of that line
- ;; with intersectable objects.
- ;; Kent Cooper, July 2010
- ;;;; [optional features could be added: account for other
- ;;;; Coordinate Systems; set layer and/or dimension style]
- (defun C:QDA
- (/ *error* orth osm blipm dse1 dse2 pt1 pt2 ss obj
- intp intc inclist intpt distpt distpts intclist intplist)
- (defun *error* (errmsg)
- (if (not (wcmatch errmsg "Function cancelled,quit / exit abort"))
- (princ (strcat "\nError: " errmsg))
- ); end if
- (command)
- (setvar 'osmode osm)
- (setvar 'orthomode orth)
- (setvar 'blipmode blipm)
- (setvar 'dimse1 dse1)
- (setvar 'dimse2 dse2)
- (command "_.undo" "_end")
- (setvar 'cmdecho cmde)
- ); end defun - *error*
- (vl-load-com)
- (setq cmde (getvar 'cmdecho))
- (setvar 'cmdecho 0)
- (command "_.undo" "_begin")
- (setq
- orth (getvar 'orthomode)
- osm (getvar 'osmode)
- blipm (getvar 'blipmode)
- dse1 (getvar 'dimse1)
- dse2 (getvar 'dimse2)
- ); end setq
- (setvar 'orthomode 0)
- (setq
- pt1 (getpoint "\nStarting Point of QuickDim virtual line: ")
- pt2 (getpoint pt1 "\nOther End: ")
- ss (ssget "F" (list pt1 pt2) '((0 . "*LINE,ARC,CIRCLE,ELLIPSE,RAY,SOLID,3DFACE,REGION")))
- ); end setq
- (setvar 'osmode 0)
- (setvar 'blipmode 0)
- (setvar 'dimse1 1)
- (setvar 'dimse2 1)
- (command "_.line" pt1 pt2 "")
- (setq templine (entlast))
- (repeat (sslength ss); for each object in selection
- (setq
- obj (vlax-ename->vla-object (ssname ss 0))
- intline (vlax-ename->vla-object templine)
- intp (vla-intersectwith obj intline acExtendNone); INTersection Point(s)
- intc (safearray-value (variant-value intp)); INTersection Coord's [all together]
- intclist (append intclist intc); cumulative list for all objects so far
- ); end setq
- (ssdel (ssname ss 0) ss); remove object
- ); end repeat
- (entdel templine)
- (repeat (/ (length intclist) 3); number of [apparent] intersections
- (setq
- intpt (list (car intclist) (cadr intclist) (caddr intclist)); first remaining point
- distpt (cons (distance pt1 intpt) intpt); list: distance followed by point coordinates
- distpts (cons distpt distpts); list of those lists
- intclist (cdddr intclist); remove first point's coordinates for next one
- ); end setq
- ); end repeat
- (setq intplist ; list of intersections in order of distance from pt1
- (mapcar 'cdr ; strip distances off sorted list
- (vl-sort
- distpts
- '(lambda (p1 p2) (< (car p1) (car p2))); sorted by distance [first element]
- ); end sort
- ); end mapcar
- ); end setq
- (command "_.dimaligned" (car intplist) (cadr intplist) (cadr intplist))
- (setq intplist (cddr intplist)); remove first two points [already used]
- (while intplist ; as long as there's still another point
- (command "_.dimcontinue" (car intplist) "" "")
- (setq intplist (cdr intplist))
- ); end while
- (setvar 'osmode osm)
- (setvar "orthomode" orth)
- (setvar 'blipmode blipm)
- (setvar 'dimse1 dse1)
- (setvar 'dimse2 dse2)
- (command "_.undo" "_end")
- (setvar 'cmdecho cmde)
- (princ)
- ); end defun - QDA
- (prompt "\nType QDA for QuickDimAligned collinear intersection dimensions.")
- (princ)
|