11
AutoLISP (Vanilla / Visual) / Re: Modify DWGUNITS
« Last post by ScottMC on Today at 09:55:58 AM »With my ancient A2K, this works: (setvar "LUNITS" 2) <- for decimal
I just evaluated LoopCAD and put in a purchase request. It was denied because apparently, they would not even discuss "security" and other things with Legal and IT. My request was denied.None of my business, but… what did they say? Like no answer or ..Go away or I shall taunt you a second time!
(defun c:xdtb_pl_tolerase (/ E typ blkname ss fence-box plane)
(xd::doc:getdouble
(xdrx-string-multilanguage
"\n搜索范围"
"\nSearch range tolerance"
)
"#xd-var-global-search-tol"
(xd::doc:getpickboxheight)
)
(xd::doc:getdouble
(xdrx-string-multilanguage
"\n点线容差精度"
"Point and line tolerance"
)
"#xd-var-global-tol-dist"
(xdrx-getvar "equalpoint")
)
(if (and (setq e (car (xdrx-entsel
(xdrx-string-multilanguage
"\n拾取特征图元类型<退出>:"
"\nPick feature entity type<Exit>:"
)
)
)
)
(setq typ (assoc 0 (entget e))
blkname (xdrx-getpropertyvalue e "name")
)
(setq ss (xdrx-ssget
(xdrx-string-multilanguage
"\n选择多段线<退出>:"
"\nSelect Polyline<Exit>:"
)
'((0 . "*polyline"))
)
)
)
(progn
(xdrx-begin)
(mapcar
'(lambda (x)
(if (and (setq fence-box (xdrx-getpropertyvalue
x
"tofence"
#xd-var-global-search-tol
1
)
)
(setq fence-box (xdrx-getsamplept fence-box))
(setq
ss1 (ssget "cp"
fence-box
(list typ)
)
ss2 (ssget "f" (xdrx-getsamplept x) (list typ))
)
)
(progn
(setq nums 0
plane (xdrx-getpropertyvalue x "plane" t)
)
(mapcar '(lambda (y)
(setq position (xdrx-getpropertyvalue
y
"position"
)
closest (xdrx-getpropertyvalue
x
"getclosestpointto"
position
)
position (xdrx-point-orthoproject position plane)
closest (xdrx-point-orthoproject closest plane)
)
(if (not (equal closest position #xd-var-global-tol-dist))
(progn
(setq nums (1+ nums))
(xdrx-entity-delete y)
)
)
)
(xdrx-ss->ents ss1)
)
(xdrx-prompt
(xdrx-string-formatex
(xdrx-string-multilanguage
"\n共删除了 %d 个容差范围内的不在多段线线上的图块."
"\nA total of %d tiles matching the feature criteria were deleted."
)
nums
)
)
)
)
)
(xdrx-ss->ents ss)
)
(xdrx-end)
)
)
(princ)
)
(defun C:TEST ( )
(if (setq en (car (entsel "\n. Pick one Anonymous block: ")))
(progn
;;
;; Get list of Texts inside block
;;
(setq txtlst (GET-TxtLstFromAnonBlock en))
;; Pick one to Process
(if (setq idx (LM:listbox-V12 " Select Elevation Data " txtlst 2))
(setq idx (car idx))
)
(princ "\n. Select Block to Convert: ")
(setq filter '(( 0 . "INSERT")))
(setq sset (ssget filter))
(setq counter (sslength sset))
(setq idxcounter 0)
(while sset
(setq enm (ssname sset 0))
(MakeCOGOPOINT enm idx)
(setq sset (ssdel enm sset))
(if (zerop (sslength sset))
(setq sset nil)
);end if
(setq idxcounter (+ idxcounter 1))
);end of while
(if (> counter 0)
(princ (strcat "\n. Anonymous Blocks: " (itoa counter)
" selected, " (itoa idxcounter)
" Processed"
)
)
);end if
);end progn
);end if
(setmode *mod2)
(OldErrTrap)
(princ)
)
(defun dxf-code (code enm /) (cdr (assoc code (entget enm))))
(defun GET-TxtLstFromAnonBlock (en)
(if (AND (= (dxf-code 0 en) "INSERT") ;Check if it's an inserted block reference
(= "*U" (substr (dxf-code 2 en) 1 2))
)
(progn
(setq blkname (dxf-code 2 en)) ;Get the block's name from the Insert's DXF data
(setq a (tblobjname "BLOCK" blkname))
(setq txlst '())
(setq data (entget a))
(while a
(if (setq a (entnext a))
(progn
(setq etype (cdr (assoc 0 (entget a))))
(if (= etype "MTEXT")
(progn
(setq txt (dxf-code 1 a))
(setq txlst (append txlst (list txt)))
);end progn
);end if
);end progn
);end if
);end while
);end progn
);end if
txlst
)
(defun MakeCOGOPOINT ( en idx / blkname bn)
(if (AND (= (dxf-code 0 en) "INSERT") ;Check if it's an inserted block reference
(= "*U" (substr (dxf-code 2 en) 1 2))
)
(progn
(setq blkname (dxf-code 2 en)) ;Get the block's name from the Insert's DXF data
(setq ipt (dxf-code 10 en))
(setq a (tblobjname "BLOCK" blkname))
(setq data (entget a))
(setq txlst '())
(while a
(if (setq a (entnext a))
(progn
(setq etype (cdr (assoc 0 (entget a))))
(if (= etype "MTEXT")
(progn
(setq txt (dxf-code 1 a))
(setq txlst (append txlst (list txt)))
);end progn
);end if
);end progn
);end if
);end of while
(setq txtelev (nth idx txlst))
(if (Setq elev (distof txtelev))
(command "Point" (mapcar '+ (2D-Of ipt) (list 0.0 0.0 elev)))
)
);end progn
);end if
);end defun
;; List Box - Lee Mac
;; Displays a DCL list box allowing the user to make a selection from the supplied data.
;; msg - [str] Dialog label
;; lst - [lst] List of strings to display
;; bit - [int] 1=allow multiple; 2=return indexes
;; Returns: [lst] List of selected items/indexes, else nil
(defun LM:listbox-V12 ( msg lst bit / dch des tmp rtn )
(cond
( (not
(and
(setq tmp (vl-filename-mktemp nil nil ".dcl"))
(setq des (open tmp "w"))
(write-line
(strcat "listbox:dialog{label=\"" msg "\";spacer;:list_box{key=\"list\";multiple_select="
(if (= 1 (logand 1 bit)) "true" "false") ";width=50;height=25;}spacer;ok_cancel;}" ;;; TINGGI ASALNYA 15
)
des
)
(not (close des))
(< 0 (setq dch (load_dialog tmp)))
(new_dialog "listbox" dch)
)
)
(prompt "\nError Loading List Box Dialog.")
)
( t
(start_list "list")
(foreach itm lst (add_list itm))
(end_list)
(setq rtn (set_tile "list" "0"))
(action_tile "list" "(setq rtn $value)")
(setq rtn
(if (= 1 (start_dialog))
(if (= 2 (logand 2 bit))
(read (strcat "(" rtn ")"))
(mapcar '(lambda ( x ) (nth x lst)) (read (strcat "(" rtn ")")))
)
)
)
)
)
(if (< 0 dch)
(unload_dialog dch)
)
(if (and tmp (setq tmp (findfile tmp)))
(vl-file-delete tmp)
)
rtn
)
I just evaluated LoopCAD and put in a purchase request. It was denied because apparently, they would not even discuss "security" and other things with Legal and IT. My request was denied.None of my business, but… what did they say? Like no answer or ..Go away or I shall taunt you a second time!