坐标提取lisp程序
如何在CAD中提取坐标信息
如何在CAD中提取坐标信息在CAD(计算机辅助设计)软件中,提取坐标信息是非常重要的。
通过准确获取元素的坐标信息,我们可以更好地进行测量、布局和设计。
下面将介绍几种在CAD中提取坐标信息的常用方法和技巧。
1. 使用坐标显示功能CAD软件通常具有坐标显示功能,可以在元素上显示其坐标信息。
首先,选择要获取坐标的元素,例如点、线、弧等。
然后,在CAD软件的工具栏或菜单中找到坐标显示功能并激活它。
在鼠标拖动元素的过程中,将会实时显示元素的坐标信息。
通过这种方法,我们可以直接将元素的坐标信息提取出来。
2. 使用命令行大多数CAD软件都提供了命令行功能,可以通过输入特定命令来提取坐标信息。
首先,选择要获取坐标的元素,然后打开命令行。
输入适当的命令,如“坐标”、“坐标提取”等。
接下来,按下回车键,软件将返回元素的坐标信息。
通过这种方法,我们可以通过简单的命令来提取坐标信息。
3. 使用属性编辑器属性编辑器是一个强大的工具,可以用于提取和编辑元素的属性信息,包括坐标。
首先,选择要获取坐标的元素,然后打开属性编辑器。
在属性编辑器中,可以找到元素的坐标属性。
通过查看和编辑这些属性,我们可以轻松地提取元素的坐标信息。
4. 使用坐标提取工具有些CAD软件提供了专门的坐标提取工具,可以更方便地获取坐标信息。
这些工具通常可以通过工具栏或菜单进行访问。
选择要获取坐标的元素,然后激活坐标提取工具。
通过点击元素或拖动鼠标,软件将实时显示元素的坐标信息。
通过这种方法,我们可以直观地提取元素的坐标信息。
5. 使用LISP程序对于熟悉LISP编程语言的用户来说,可以编写自定义的LISP程序来提取坐标信息。
通过编写相应的LISP程序,可以实现更复杂的坐标提取功能。
具体的编程细节超出了本篇文章的范围,但通过使用LISP程序,我们可以根据自己的需求提取坐标信息。
综上所述,提取坐标信息是CAD中非常重要的一个环节。
通过上述几种方法和技巧,在CAD软件中准确提取坐标信息将变得更加容易。
桩自动编号并提取坐标程序使用说明
工程桩自动编号并提取坐标程序使用说明一、加载和执行程序用AutoCAD打开一个要编号的图形,在命令行输入appload命令加载xzbh9-4.vlx程序成功后,在命令行输入xzbh回车,即可执行程序。
第一次使用会弹出“申请注册码”对话框,注册后不再弹出。
图1 申请注册码对话框取得注册码后,填入图1相应位置点确定,即可注册成功,随即会进入程序主对话框,如下:图2 工程桩自动编号并提取坐标程序主对话框二、具体操作说明1、操作前准备工作首先要保证每根桩都是独立的桩,假如所有的桩是一个整块或每组承台内的桩是一个整块,需要提前批量炸开后再执xzbh。
2、必选项操作操作时,“桩所在图层”和“桩型”这两个是必选项,必须要根据当前图设置正确,该程序就是根据这两项来选择符合条件的桩,如果这两项设置和当前编号图纸中的桩不对应,则会出现无法选择到桩对象的情况。
“桩所在图层”可以通过点“选取”按钮指定一个桩进行设置,或者在文本框内手工输入桩所在的图层名进行设置。
点“选取”按钮时,会关闭主对话框,并在命令行提示“指定一个桩对象:”,这时在图面上点取一个桩后,程序会自动又返回主对话框,并在“桩所在图层”文本框内显示刚才点取那个桩的图层名。
“桩型”可以在执行xzbh前,用list命令查看下桩是哪个对象类型,然后将相应桩型勾选即可,当有多个桩型时可多选。
3、主对话框中,除“桩所在图层”和“桩型”两项外,其它的都是可选项。
下面一一说明(1)主对话框中“排序次序”一栏用于设置桩编号顺序,例如: 选择的排序为:先从上到下、再从左到右,则所有选择到的桩对象,按其中心点坐标Y值从大到小进行排序,假如坐标Y值相同(相当于同在一行),则会按其坐标X值再从小到大进行排序。
选择的排序为:先从上到下、再从左到右,且“并兼顾S形排序”也同时勾选时,则所有选择到的桩对象,按其中心点坐标Y值从大到小进行排序,假如坐标Y值相同(相当于同在一行),则奇数行会按其坐标X值再从小到大进行排序,偶数行会按其坐标X值再从大到小进行排序。
标注坐标的lisp程序
标注坐标的lisp程序1、新建一个TXT文本文件,并将下面代码复制进文本内,如下图:2、将该文本文件保存并修改文件名为bzzb.lsp,这里的扩展名一定要改成lsp哦!然后就如下图这样3、在任何版本的AUTOCAD软件内命令行内输入“appload”命令,然后选择该文件进行加载程序,如下图4、程序加载好后,就可以在命令行内输入“bz”命令进行对图中文字注记进行分层显示了。
(defun c:bz();标注坐标(setvar "cmdecho" 0)(command "osnap" "app,end,center")(setq zbd (getpoint "\n请点击要标注坐标的点:"))(command "osnap" "off")(setq zbd2 (getpoint "\n请点击伸出的第二个点:"))(command "line" zbd zbd2 "")(setq zbd2x (car zbd2))(setq zbd2y (cadr zbd2))(setq zbdx (car zbd))(setq zbdy (cadr zbd))(if (>= zbd2x zbdx)(progn(command "line" zbd2 (list (+ zbd2x 30) zbd2y) "")(command "text" "s" "Standard" "j" "bl" (list (+ zbd2x 1.2) (+ zbd2y 1)) "2" "0" (strcat "X = " (rtos zbdy 2 3)))(command "text" "s" "Standard" "j" "tl" (list (+ zbd2x 1.2) (- zbd2y 1)) "2" "0" (strcat "Y = " (rtos zbdx 2 3))))(progn(command "line" zbd2 (list (- zbd2x 30) zbd2y) "")(command "text" "s" "Standard" "j" "bl" (list (- zbd2x 28) (+ zbd2y 1)) "2" "0" (strcat "X = " (rtos zbdy 2 3)))(command "text" "s" "Standard" "j" "tl" (list (- zbd2x 28) (- zbd2y 1)) "2" "0" (strcat "Y = " (rtos zbdx 2 3))))))。
坐标提取lisp程序
坐标提取lisp程序2010-05-17 20:50:07| 分类:工程 | 标签: |字号大中小订阅;该程序主要用于CAD点(point)三维坐标提取,并将数据输出为CASS软件中使用的数据格式;输出格式:点号,,测量Y值,测量X值,测量Z值例:1,,100.3244,1232,433,25;2010-05-17;命令:plzbsc(defun c:plzbsc()(princ "\n选择所需输出的点(point):")(setq ss (ssget ));;选取坐标点(setq n (sslength ss ));计算坐标点数量(setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径(setq i 0)(repeat n(setq spt (ssname ss i ))(setq ept (entget spt))(if (= (cdr (assoc 0 ept)) "POINT")(progn(setq lxyz (cdr (assoc 10 ept)))(setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符(setq sy (rtos (nth 0 lxyz)))(setq sz (rtos (nth 2 lxyz)))(setq i1 (+ i 1));计算点序号(setq sn (rtos i1 2 0));将序号实数转换成字符(setq sxyz (strcat sn",," sy "," sx "," sz))(write-line sxyz ff)))(setq i (+ i 1)));repeat)(prompt "* << 命令:plzbsc >> *输出格式(点号,, Y,X,Z)**") (prin1)地形图上提取碎步点(高程点)坐标并输出到文本2010-05-18 08:50:38| 分类:工程 | 标签: |字号大中小订阅利用程序提取地形图上碎步点的三维坐标。
CAD_XY坐标标注AUTO_LISP程序
CAD X,Y坐标坐标标注AUTO LISP程序;; (DEFUN IDPT(/ p px py pxx pyy)(DEFUN IDPT ()(SETQ X T)(WHILE X(SETV AR "OSMODE" (+ 1 32 512))(INITGET 1)(SETQ PP (GETPOINT "\nPLEASE PICK THE POINT:")) (SETV AR "OSMODE" 0)(SETQ P (OSNAP PP "INT,END,CEN"))(IF (= P NIL)(PROMPT "\nINV ALID POINT, PICK !")(SETQ X NIL)))(SETQ PXX (CAR P)PYY (CADR P)PX (RTOS PXX 2 PRE1)PY (RTOS PYY 2 PRE1)));;(DEFUN MAX_XY(WI PX PY / L PXPX PYPY) (DEFUN MAX_XY ()(SETQ KKK "X")(SETQ LLL "Y")(SETQ LX (STRLEN PX)L Y (STRLEN PY))(IF (> LX L Y)(PROGN(SETQ W_NU (- LX L Y))(WHILE (> W_NU 0)(SETQ PY (STRCAT " " PY))(SETQ W_NU (- W_NU 1)))))(IF (< LX L Y)(PROGN(SETQ W_NU (- L Y LX))(WHILE (> W_NU 0)(SETQ PX (STRCAT " " PX))(SETQ W_NU (- W_NU 1)))))(SETQ PYPY (STRCAT KKK PY))(SETQ PXPX (STRCAT LLL PX))(SETQ PXL (STRLEN PXPX)PYL (STRLEN PYPY)MAXL (FLOAT (MAX PXL PYL))L (* WI MAXL)));;(DEFUN TEXT_P(/ W WX WY)(DEFUN TEXT_P ()(SETV AR "OSMODE" 0)(INITGET 1)(SETQ W (GETPOINT "\nINPUT X-Y TEXT POSITION:")) (SETQ WX (CAR W))(SETQ WY (CADR W)));;(DEFUN DRLIN(CAL P W L / ALPW WE)(DEFUN DRLIN ()(SETQ AL01 (+ PI CAL))(SETQ ALPW (ANGLE P W))(SETQ AG-D (- ALPW CAL))(IF (> AG-D 0)(PROGN(IF (AND (< AG-D (* PI 0.5)) (> AG-D (* PI 0))) (SETQ WE (POLAR W CAL L)BZ 1))(IF (AND (> AG-D (* PI 0.5)) (< AG-D (* PI 1.5))) (SETQ WE (POLAR W AL01 L)BZ 2))(IF (AND (> AG-D (* PI 1.5)) (< AG-D (* PI 2))) (SETQ WE (POLAR W CAL L)BZ 3));>>>>>)(PROGN;<<<<<(IF (AND (> AG-D (* PI -0.5)) (< AG-D (* PI 0))) (SETQ WE (POLAR W CAL L)BZ 1))(IF (AND (< AG-D (* PI -0.5)) (> AG-D (* PI -1.5))) (SETQ WE (POLAR W AL01 L)BZ 2))(IF (AND (< AG-D (* PI 1.5)) (> AG-D (* PI -2))) (SETQ WE (POLAR W CAL L)BZ 3));>>>>>))(COMMAND "PLINE" P "W" 0.0 "" W WE ""));;(DEFUN DRCORD(AL01 ALPW H CAL PXPX PYPY /)(DEFUN DRCORD ()(IF (= BZ 2)(SETQ WB WE)(SETQ WB W))(SETQ WBX (POLAR WB (+ (* PI 0.5) CAL) H)WBY (POLAR WB (+ (* PI 1.5) CAL) H))(SETQ AL_CAL (* 180 (/ CAL PI)))(COMMAND "TEXT" "J" "ML" WBX H AL_CAL PYPY) (COMMAND "TEXT" "J" "ML" WBY H AL_CAL PXPX));;(DEFUN DRELEV(AL01 ALPW WE CAL WI PRE2)(DEFUN DRELEV ()(IF (< WX PXX)(SETQ EPL (POLAR WE AL01 (* WI 0.5)))(SETQ EPR (POLAR WE CAL (* WI 0.5))))(SETQ DHH (GETREAL "\nINPUT DESIGN ELEV A TION:"))(IF (= DHH NIL)(PROMPT "\nNO ELEV ATION A V AILABLE NOW!")(PROGN(SETQ DH (RTOS DHH 2 PRE2))(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "ELEV")(ELA))(IF (< WX PXX)(COMMAND "TEXT" "J" "MR" EPL H AL_CAL DH)(COMMAND "TEXT" "J" "ML" EPR H AL_CAL DH)))))(DEFUN PCR ()(SETQ TS 0.0)(SETV AR "OSMODE" 33)(SETQ X T)(WHILE X(INITGET 1)(SETQ PP1 (GETPOINT "\nENTER THE FIRST POINT:"))(SETQ P1 (OSNAP PP1 "INT,END"))(IF (/= P1 NIL)(SETQ X NIL)(PROGN (PROMPT "\nNO INT OR END FOUND, CONTINUE? [Y/N]") (INITGET 1)(SETQ J (GETSTRING))(IF (OR (= J "Y") (= J "y"))(PROGN (SETQ P1 PP1) (SETQ X NIL))(PROMPT "\nRESELECT PLEASE!")))))(SETQ OP1 P1)(SETQ P_NUMBER 1)(SETQ X T)(WHILE X(SETQ P_NUMBER (+ 1 P_NUMBER))(SETQ PRO_1 (STRCAT "\n THE <" (ITOA P_NUMBER)))(SETQ PRO_1 (STRCAT PRO_1 "> POINT(ENTER=END SELECT:)"))(SETQ P2 (GETPOINT PRO_1))(IF (/= P2 NIL)(PROGN (SETQ SS(* (+ (CADR P1) (CADR P2)) (- (CAR P2) (CAR P1)) 0.5) )(SETQ TS (+ TS SS))(SETQ P1 P2))(PROGN (SETQ SS(* (+ (CADR OP1) (CADR P1)) (- (CAR OP1) (CAR P1)) 0.5) )(SETQ TS (+ TS SS))(SETQ X NIL))))(SETQ S0 (ABS TS))(SETQ TSS (RTOS S0 2 PRE3))(SETV AR "OSMODE" 0)(INITGET 1)(SETQ W (GETPOINT "\nINPUT TEXT POSITION:"))(COMMAND "TEXT" W H 0.0 (STRCAT "S=" TSS)))(DEFUN ETP ()(SETQ X T)(WHILE X(PROMPT "\nSELECT EDGE OF THE POL YGON:")(SETQ S_SET (SSGET))(IF (= S_SET NIL)(PROMPT "\nINV ALID SELECTION, RESELECT PLEASE!")(SETQ X NIL)))(CA_AREA))(DEFUN LTP ()(INITGET 1)(SETQ URC (GETCORNER(SETQ DLC (GETPOINT "\nENTER FIRST CORNER:"))"\nTHE SECOND CORNER:"))(SETQ SSET (SSGET "W" DLC URC))(COND((OR (= ENTP "LINE") (= ENTP "ARC"))(COMMAND "PEDIT" (SSGET P10) "Y" "J" SSET "" "X"))((= ENTP "POL YLINE")(COMMAND "PEDIT" (SSGET P10) "J" SSET "" "X"))(T (PROMPT "\nINV ALID ENTITY FOR PEDIT!"))))(DEFUN RETP ()(SETQ SET1 (SSGET P10))(SETQ ENAME (SSNAME SET1 0))(SETQ ELIST (ENTGET ENAME))(SETQ ENTP (CDR (ASSOC 0 ELIST))))(DEFUN PLTP ()(SETQ ENTP2 (CDR (ASSOC 70 ELIST))))(DEFUN PLS ()(PLTP)(IF (= ENTP2 1)(PROGN (REDRAW ENAME 3)(PROMPT "\nIT'S A CLOSED POL YLINE")(S))(PROGN(REDRAW ENAME 3)(PROMPT "\nIT'S NOT A CLOSED PLINE, TRY TO CLOSE IT!")(LTP)(RETP)(PLTP)(IF (= ENTP2 1)(PROGN (PROMPT "\nNOW IT HAS BEEN CLOSED!")(S))(PROGN (REDRAW ENAME 3)(SETQ X(GETSTRING(STRCAT"\nCAN'T BE CLOSED AUTOMA TICALL Y, CALCULATE IST AREA?""\n<'Y' FOR YES AND ANY OTHER KEY FOR NO>")))(IF (OR (= X "Y") (= X "y"))(S)(PROMPT "\nTHIS ONE IGNORED, CALCULATE NEXT POL YGON!")))))))(DEFUN S ()(COMMAND "AREA" "E" (SSGET P10))(SETQ SS (GETV AR "AREA"))(SETQ S1 (RTOS SS 2 PRE3))(SETV AR "OSMODE" 0)(INITGET 1)(SETQ PT (GETPOINT "\nINPUT TEXT POSITION:"))(COMMAND "TEXT" PT H 0.0 (STRCAT "S=" S1)))(DEFUN THN ()(IF (/= B0 NIL)(PROGN(SETQ BI (RTOS B0 2 1))(INITGET 6)(SETQB (GETREAL(STRCAT "\nINPUT MAP SCALE FACTOR [1:X*1000]/<" BI ">")))(IF (= B NIL)(SETQ B B0)(SETQ B0 B)))(PROGN(INITGET 7)(SETQ B (GETREAL "\nINPUT MAP SCALE FACTOR [1:X*1000]"))(SETQ B0 B)))(IF (/= CAL0 NIL)(PROGN(SETQ CAL1 (RTOS CAL0 2 1))(INITGET 8)(SETQ CAL2 (GETREAL(STRCAT "\nINPUT TEXT ROTATE ANGLE[d]/<" CAL1 ">")))(IF (= CAL2 NIL)(SETQ CAL (/ (* PI CAL0) 180))(PROGN(SETQ CAL (/ (* PI CAL2) 180))(SETQ CAL0 CAL2))))(PROGN (INITGET 8)(SETQ CAL2 (GETREAL "\nINPUT TEXT ROTATE ANGLE[d]:"))(SETQ CAL (/ (* PI CAL2) 180))(SETQ CAL0 CAL2)))(IF (/= HH0 NIL)(PROGN(SETQ HHI (RTOS HH0 2 1))(INITGET 6)(SETQ HH (GETREAL(STRCAT "\nINPUT TEXT HEIGHT [mm]/<" HHI ">")))(IF (= HH NIL)(SETQ HH HH0)(SETQ HH0 HH)))(PROGN (INITGET 7)(SETQ HH (GETREAL "\nINPUT TEXT HEIGHT [MM]:"))(SETQ HH0 HH)))(SETQ H (* HH B))(IF (= WF NIL)(SETQ WF 1.0))(SETQ WI (* H WF)))(DEFUN PRE1N ()(IF (/= PRE10 NIL)(PROGN (SETQ PRE1I (RTOS PRE10 2 0))(INITGET 4)(SETQPRE1 (GETINT(STRCA T "\nINPUT DECIMAL PLACE FOR X-Y COORDINATE <"PRE1I">:")))(IF (= PRE1 NIL)(SETQ PRE1 PRE10)(SETQ PRE10 PRE1)))(PROGN (INITGET 5)(SETQ PRE1(GETINT "\nINPUT DECIMAL PLACE FOR X-Y COORDINATE:") )(SETQ PRE10 PRE1))))(DEFUN PRE2N ()(IF (/= PRE20 NIL)(PROGN (SETQ PRE2I (RTOS PRE20 2 0))(INITGET 4)(SETQ PRE2 (GETINT(STRCAT "\nINPUT DECIMAL PLACE FOR ELEV ATION <"PRE2I">:")))(IF (= PRE2 NIL)(SETQ PRE2 PRE20)(SETQ PRE20 PRE2)))(PROGN (INITGET 5)(SETQ PRE2(GETINT "\nINPUT DECIMAL PLACE FOR ELEV A TION:"))(SETQ PRE20 PRE2))))(DEFUN PRE3N ()(IF (/= PRE30 NIL)(PROGN (SETQ PRE3I (RTOS PRE30 2 0))(INITGET 4)(SETQ PRE3(GETINT(STRCA T "\nINPUT DECIMAL PLACE FOR AREA IDENTIFICATION <"PRE3I">:")))(IF (= PRE3 NIL)(SETQ PRE3 PRE30)(SETQ PRE30 PRE3)))(PROGN (INITGET 5)(SETQ PRE3(GETINT "\nINPUT DECIMAL PLACE FOR AREA IDENTIFICATION:") )(SETQ PRE30 PRE3))))(DEFUN XYZ ()(THN)(PRE1N)(PRE2N)(SETQ XX T)(WHILE XX(INITGET "Exit Continue")(SETQ ZZ (GETKWORD "\nExit/Continue?/<Continue>"))(COND((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "CORD")(XYLA))(IDPT);;(TEXT_P);; (MAX_XY WI PX PY L)(MAX_XY);; (DRLIN CAL P W L)(DRLIN);; (DRCORD AL01 ALPW H CAL PXPX PYPY)(DRCORD);; (DRELEV AL01 ALPW WE CAL WI PRE2)(DRELEV)))))(DEFUN FIX ()(THN)(PRE1N)(PRE2N)(SETQ XX2 T)(WHILE XX2(SETQ XX3 NIL)(IDPT)(ALN1)(SETQ XX T)(WHILE XX(INITGET "Help Exit COntinue CHangepar")(SETQ ZZ (GETKWORD "\nHelp/Exit/COntinue/CHangepar?/<COntinue>"))(COND((= ZZ "Help")(TEXTPAGE)(PROMPT"\n ENTER A V ALUE OR A POINT TO DEFINE THE LENGTH OF OBLIQUAL BASELINE AND")(PROMPT"\nENTER A POINT IN ONE OF THE FOUR QAUDRANTS TO SELECT THE DIRECTION OF THE ")(PROMPT"\nOBLIQUAL BASELINE OR PRESS 'ENTER' TO SELECT THE DEFAULT V ALUES."))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NILXX2 NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "CORD")(XYLA))(IF (= XX3 T)(IDPT))(SETQ XX3 T)(CPXY)(ALN2)(TBL)(CORD)(DE))((= ZZ "CHangepar") (SETQ XX NIL))))))(DEFUN AE ()(ELA)(THN)(PRE2N)(SETQ XX T)(WHILE XX(INITGET "Help Exit Continue")(SETQ ZZ (GETKWORD "\nHelp/Exit/Continue?/<Continue>"))((= ZZ "Help")(TEXTPAGE)(PROMPT"\n FIRST SELECT THE ID POINT, THEN SELECT THE END OF THE")(PROMPT "\nHORIZONTAL BASELINE;"))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETV AR "OSMODE" 1)(SETQ PP (GETPOINT "\nSELECT THE ID POINT:"))(SETQ P (OSNAP PP "END"))(SETQ PXX (CAR P))(SETQ X T)(WHILE X(SETQ WEE (GETPOINT "\nINPUT THE TEXT POSITION:"))(SETQ WE (OSNAP WEE "END"))(IF (= WE NIL)(PROMPT "\nINV ALID POSITION, RESELECT PLEASE!")(SETQ X NIL)))(SETQ WX (CAR WE))(SETV AR "OSMODE" 0)(DE)))))(DEFUN PLGS ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(ETP)(SETV AR "osmode" 0)(SETQ PT (GETPOINT "\n Please input TEXT POSITION:")) (COMMAND "text"PTH0.0(STRCAT "S=" S_AREA)))(DEFUN CA_AREA ()(SETQ ENT_NAME (SSNAME S_SET 0))(SETQ ENT_NUM (SSLENGTH S_SET))(SETQ T_AREA 0LOOP 0NUM 0)(WHILE LOOP(COMMAND "AREA" "E" ENT_NAME)(SETQ S1_AREA (LIST (GETV AR "AREA")))(SETQ S2_AREA (CAR S1_AREA))(SETQ T_AREA (+ T_AREA S2_AREA))(SETQ NUM (+ NUM 1))(SETQ ENT_NAME (SSNAME S_SET NUM))(IF (= NUM ENT_NUM)(SETQ LOOP NIL)))(SETQ S_AREA (RTOS T_AREA 2 PRE3)))(DEFUN E_LAYER ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(SETQ L_NAME (GETSTRING "\nPlaese input LAYER NAME:")) (SETQ S_SET (SSGET "X"(LIST (CONS 0 "POL YLINE")(CONS 8 L_NAME))))(CA_AREA)(SETV AR "osmode" 0)(INITGET 1)(SETQ PT (GETPOINT "\n Please input TEXT POSITION:")) (COMMAND "text"PTH0.0(STRCAT "The layer<" L_NAME ">S=" S_AREA)))(DEFUN E_COLOR ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(SETQ C_NAME (GETINT "\nPlaese input COLOR NAME:")) (SETQ S_SET (SSGET "X"(LIST (CONS 0 "POL YLINE")(CONS 62 C_NAME))))(CA_AREA)(SETV AR "osmode" 0)(INITGET 1)(SETQ PT (GETPOINT "\n Please input TEXT POSITION:")) (COMMAND "text"PTH0.0(STRCAT "The color <" (RTOS C_NAME 2 0) ">S=" S_AREA) ))(DEFUN POS ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(SETQ XX T)(WHILE XX(INITGET "Help Exit Continue")(SETQ ZZ (GETKWORD "\nHelp/Exit/Continue?/<Continue>"))(COND((= ZZ "Help")(TEXTPAGE)(PROMPT"\n ENTER THE POINTS TO DEFINE THE EDGE OF THE REGION")(PROMPT"\nTO BE CALCULATED AND IDed, AFTER LAST POINT ENTERED,")(PROMPT"\nPRESS 'ENTER' AND THEN SELECT A POINT TO DEFINE THE")(PROMPT "\nPOSITION OF THE AREA ID TEXT."))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(PCR)))))(DEFUN XYLA ()(COMMAND "LAYER" "M" "CORD" "C" "CYAN" "" ""))(DEFUN ELA ()(COMMAND "LAYER" "M" "ELEV" "C" "CYAN" "" ""))(DEFUN SLA ()(COMMAND "LAYER" "M" "AREA" "C" "CYAN" "" ""))(DEFUN ALN1 ()(IF (/= AL0 NIL)(PROGN (SETQ ALI (RTOS AL0 2 1))(INITGET 70)(PROMPT(STRCAT "\nINPUT OBLIQUAL LINE LENGTH [DRAWING UNIT]/<"ALI">:"))(SETQ ALL (GETDIST P))(IF (= ALL NIL)(SETQ ALL AL0)(SETQ AL0 ALL)))(PROGN (INITGET 71)(SETQ ALL (GETDIST P"\nINPUT OBLIQUAL LINE LENGTH [DRAWING UNIT]"))(SETQ AL0 ALL)))(IF (/= WA0 NIL)(PROGN(SETQ WAI (ANGTOS W A0 0 0))(PROMPT(STRCAT "\nCHOOSE THE DIRECTION OF THE OBLIQUAL LINE<"WAI"d>:"))(SETQ DRL (GETANGLE P))(IF (= DRL NIL)(SETQ W A WA0)(PROGN(COND((< DRL (* PI 0.5))(SETQ W A (* PI 0.25)))((< DRL PI)(SETQ W A (* PI 0.75)))((< DRL (* PI 1.5))(SETQ W A (* PI 1.25)))((< DRL (* PI 2.0))(SETQ W A (* PI 1.75)))))))(PROGN (INITGET 1)(SETQDRL (GETANGLE P"\nCHOOSE THE DIRECTION OF THE OBLIQUAL LINE:"))(COND((< DRL (* PI 0.5))(SETQ WA (* PI 0.25)))((< DRL PI)(SETQ WA (* PI 0.75)))((< DRL (* PI 1.5))(SETQ WA (* PI 1.25)))((< DRL (* PI 2.0))(SETQ WA (* PI 1.75))))(SETQ WA0 WA))))(DEFUN ALN2 ()(SETQ W (POLAR P (+ CAL WA) ALL))(SETQ WX (CAR W)))(DEFUN TSET ()(SETV AR "FILEDIA" 0)(SETQ WFF (GETREAL"\nINPUT THE WIDTH-HEIGHT FACTOR OF TEXT<1.0>:"))(IF (= WFF NIL)(SETQ WF 1.0))(COMMAND "STYLE" "STANDARD" "MONOTXT" "0.0" WF "0" "N" "N" "N") (SETV AR "FILEDIA" 1)(COMMAND "COLOR" "BYLAYER")(PRINC))(DEFUN CO-ZOOM ()(PROMPT "\nTURN OFF ALL UNCONCERN LAYERS!")(IF (/= CS0 NIL)(PROGN (SETQ CSI (RTOS CS0 2 1))(INITGET 6)(PROMPT (STRCAT "\nINPUT CURRENT SCALE FACTOR<" CSI ">:"))(SETQ CS (GETREAL))(IF (= CS NIL)(SETQ CS CS0)(SETQ CS0 CS)))(PROGN (SETQ CS (GETREAL "\nINPUT CURRENT SCALE FACTOR:")) (SETQ CS0 CS)))(IF (/= DS0 NIL)(PROGN (SETQ DSI (RTOS DS0 2 1))(INITGET 6)(PROMPT (STRCAT "\nINPUT PREFER SCALE FACTOR<" DSI ">:"))(SETQ DS (GETREAL))(IF (= DS NIL)(SETQ DS DS0)(SETQ DS0 DS)))(PROGN (SETQ DS (GETREAL "\nINPUT PREFER SCALE FACTOR:")) (SETQ DS0 DS)))(SETQ FTOR (/ DS CS))(SETQ XX T)(WHILE XX(INITGET "Help Exit Continue")(SETQ ZZ (GETKWORD "\nHelp/Exit/Continue?/<Continue>"))(COND((= ZZ "Help")(TEXTPAGE))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETV AR "OSMODE" 32)(INITGET 1)(SETQ P (GETPOINT "\SELECT THE ID BASELINE:"))(SETQ PP (OSNAP P "END,INS"))(SETQ P2 (GETCORNER(SETQ P1 (GETPOINT "\nSELECT TEXTs IN WINDOW:"))))(SETQ SSET (SSGET "W" P1 P2))(COMMAND "SCALE" SSET "" PP FTOR)))))(DEFUN HLP ()(PROMPT "\n"))(defun-q *error* () ("PROGRAM TERMINA TED BY USER")(PRINC "\nERROR: ")(PRINC "PROGRAM TERMINA TED BY USER!")(PRINC))(DEFUN C:DM ()(PRINC)(SETQ CULA (GETV AR "CLAYER"))(SETQ XXX T)(SETQ ZP "3d")(WHILE XXX(INITGET"Help Set 3D F3d Ae APOint APLine ALayer AColor Coz Exit")(SETQZ (GETKWORD"\nHelp/Set/3D/F3d/Ae/APOint/APLine/ALayer/AColor/Coz/Exit:"))(SETQ ZP1 Z)(IF (= Z NIL)(SETQ Z ZP))(SETQ ZP ZP1)(COND((= Z "Help") (HLP))((= Z "Set") (TSET))((= Z "3D") (XYZ))((= Z "F3d") (FIX))((= Z "APOint") (POS))((= Z "APLine") (PLGS))((= Z "ALayer") (E_LAYER))((= Z "AColor") (E_COLOR))((= Z "Coz") (CO-ZOOM))((= Z "Ae") (AE))((= Z "Exit")(COMMAND "LAYER" "S" CULA "")(PROMPT "\n *** Exit from DM program, Thanks! ***")(SETQ XXX NIL))))(PRINC))。
AutoCADlisp插件三维交点坐标提取
;;;本插件为AutoCADlisp 插件,用于获取LINE 命令绘出的线段的交点,交点坐标返回为被交线段上的点(即外观交点xy+被交线段对应该点的z 值) ;;;获取切割线与相交直线的交点,返回被交线段上的交点。
(defun C:JDHQ()(setvar "cmdecho" 0)(princ "\n 选择要切割的直线:")(setq lll(entsel)); 选择直线; 取得直线起点零高程坐标列表(setq lllxyz1(cdr (assoc 10 (entget (car lll)))))(setq lllx1(nth 1 lllxyz1))(setq llly1(nth 0 lllxyz1))(setq lllxyz10 (list llly1 lllx1 0.0)); 取得直线终点零高程坐标列表(setq lllxyz2(cdr(assoc 11 (entget (car lll)))))(setq lllx2(nth 1 lllxyz2))(setq llly2(nth 0 lllxyz2))(setq lllxyz20 (list llly2 lllx2 0.0))(princ "\n 选择被相交的直线图元集:")(setq ss(ssget));被交线图元集(setq n(sslength ss)); 计算图元集图元个数(setq ff(open(getfiled " 交点保存为""""txt" 1)"w"))(setq i 0)(repeat n(setq spt (ssname ss i))(setq ept (entget spt))(if (=(cdr(assoc 0 ept)) "LINE") (progn(setq lxyz1(cdr (assoc 10 ept)))(setq sx1(nth 1 lxyz1))(setq sy1(nth 0 lxyz1))(setq sz1(nth 2 lxyz1))(setq lxyz10 (list sy1 sx1 0.0))(setq lxyz2(cdr (assoc 11 ept)))(setq sx2(nth 1 lxyz2))(setq sy2(nth 0 lxyz2))(setq sz2(nth 2 lxyz2))(setq lxyz20 (list sy2 sx2 0.0));计算交点坐标(setq jdxy0(inters lllxyz10 lllxyz20 lxyz10 lxyz20))(if (/= jdxy0 nil)(progn(setq jdx(nth 1 jdxy0))(setq jdy(nth 0 jdxy0));求交点高程z(setq l1(sqrt(+(* (- sx2 sx1) (- sx2 sx1)) (* (- sy2 sy1) (- sy2 sy1)))))(setq l2(sqrt(+(* (- jdx sx1) (- jdx sx1)) (* (- jdy sy1) (- jdy sy1)))))(setq jdz(+ sz1 (* (- sz2 sz1) (/ l2 l1))))(setq jdz1(rtos jdz 2 3))(setq jdx1(rtos jdx 2 3))(setq jdy1(rtos jdy 2 3))(setq jdxyz(strcat jdy1"," jdx1 ","jdz1))(write-line jdxyz ff)))))(setq i (+ i 1)))(close ff)(prin1))(prompt "********<<C:JDHQ>>********")(prin1)。
CAD XY坐标标注AUTO LISP程序
CAD X,Y坐标坐标标注AUTO LISP程序;; (DEFUN IDPT(/ p px py pxx pyy)(DEFUN IDPT ()(SETQ X T)(WHILE X(SETV AR "OSMODE" (+ 1 32 512))(INITGET 1)(SETQ PP (GETPOINT "\nPLEASE PICK THE POINT:")) (SETV AR "OSMODE" 0)(SETQ P (OSNAP PP "INT,END,CEN"))(IF (= P NIL)(PROMPT "\nINV ALID POINT, PICK !")(SETQ X NIL)))(SETQ PXX (CAR P)PYY (CADR P)PX (RTOS PXX 2 PRE1)PY (RTOS PYY 2 PRE1)));;(DEFUN MAX_XY(WI PX PY / L PXPX PYPY) (DEFUN MAX_XY ()(SETQ KKK "X")(SETQ LLL "Y")(SETQ LX (STRLEN PX)L Y (STRLEN PY))(IF (> LX L Y)(PROGN(SETQ W_NU (- LX L Y))(WHILE (> W_NU 0)(SETQ PY (STRCAT " " PY))(SETQ W_NU (- W_NU 1)))))(IF (< LX L Y)(PROGN(SETQ W_NU (- L Y LX))(WHILE (> W_NU 0)(SETQ PX (STRCAT " " PX))(SETQ W_NU (- W_NU 1)))))(SETQ PYPY (STRCAT KKK PY))(SETQ PXPX (STRCAT LLL PX))(SETQ PXL (STRLEN PXPX)PYL (STRLEN PYPY)MAXL (FLOAT (MAX PXL PYL))L (* WI MAXL)));;(DEFUN TEXT_P(/ W WX WY)(DEFUN TEXT_P ()(SETV AR "OSMODE" 0)(INITGET 1)(SETQ W (GETPOINT "\nINPUT X-Y TEXT POSITION:")) (SETQ WX (CAR W))(SETQ WY (CADR W)));;(DEFUN DRLIN(CAL P W L / ALPW WE)(DEFUN DRLIN ()(SETQ AL01 (+ PI CAL))(SETQ ALPW (ANGLE P W))(SETQ AG-D (- ALPW CAL))(IF (> AG-D 0)(PROGN(IF (AND (< AG-D (* PI 0.5)) (> AG-D (* PI 0))) (SETQ WE (POLAR W CAL L)BZ 1))(IF (AND (> AG-D (* PI 0.5)) (< AG-D (* PI 1.5))) (SETQ WE (POLAR W AL01 L)BZ 2))(IF (AND (> AG-D (* PI 1.5)) (< AG-D (* PI 2))) (SETQ WE (POLAR W CAL L)BZ 3));>>>>>)(PROGN;<<<<<(IF (AND (> AG-D (* PI -0.5)) (< AG-D (* PI 0))) (SETQ WE (POLAR W CAL L)BZ 1))(IF (AND (< AG-D (* PI -0.5)) (> AG-D (* PI -1.5))) (SETQ WE (POLAR W AL01 L)BZ 2))(IF (AND (< AG-D (* PI 1.5)) (> AG-D (* PI -2))) (SETQ WE (POLAR W CAL L)BZ 3));>>>>>))(COMMAND "PLINE" P "W" 0.0 "" W WE ""));;(DEFUN DRCORD(AL01 ALPW H CAL PXPX PYPY /)(DEFUN DRCORD ()(IF (= BZ 2)(SETQ WB WE)(SETQ WB W))(SETQ WBX (POLAR WB (+ (* PI 0.5) CAL) H)WBY (POLAR WB (+ (* PI 1.5) CAL) H))(SETQ AL_CAL (* 180 (/ CAL PI)))(COMMAND "TEXT" "J" "ML" WBX H AL_CAL PYPY) (COMMAND "TEXT" "J" "ML" WBY H AL_CAL PXPX));;(DEFUN DRELEV(AL01 ALPW WE CAL WI PRE2)(DEFUN DRELEV ()(IF (< WX PXX)(SETQ EPL (POLAR WE AL01 (* WI 0.5)))(SETQ EPR (POLAR WE CAL (* WI 0.5))))(SETQ DHH (GETREAL "\nINPUT DESIGN ELEV A TION:"))(IF (= DHH NIL)(PROMPT "\nNO ELEV ATION A V AILABLE NOW!")(PROGN(SETQ DH (RTOS DHH 2 PRE2))(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "ELEV")(ELA))(IF (< WX PXX)(COMMAND "TEXT" "J" "MR" EPL H AL_CAL DH)(COMMAND "TEXT" "J" "ML" EPR H AL_CAL DH)))))(DEFUN PCR ()(SETQ TS 0.0)(SETV AR "OSMODE" 33)(SETQ X T)(WHILE X(INITGET 1)(SETQ PP1 (GETPOINT "\nENTER THE FIRST POINT:"))(SETQ P1 (OSNAP PP1 "INT,END"))(IF (/= P1 NIL)(SETQ X NIL)(PROGN (PROMPT "\nNO INT OR END FOUND, CONTINUE? [Y/N]") (INITGET 1)(SETQ J (GETSTRING))(IF (OR (= J "Y") (= J "y"))(PROGN (SETQ P1 PP1) (SETQ X NIL))(PROMPT "\nRESELECT PLEASE!")))))(SETQ OP1 P1)(SETQ P_NUMBER 1)(SETQ X T)(WHILE X(SETQ P_NUMBER (+ 1 P_NUMBER))(SETQ PRO_1 (STRCAT "\n THE <" (ITOA P_NUMBER)))(SETQ PRO_1 (STRCAT PRO_1 "> POINT(ENTER=END SELECT:)"))(SETQ P2 (GETPOINT PRO_1))(IF (/= P2 NIL)(PROGN (SETQ SS(* (+ (CADR P1) (CADR P2)) (- (CAR P2) (CAR P1)) 0.5) )(SETQ TS (+ TS SS))(SETQ P1 P2))(PROGN (SETQ SS(* (+ (CADR OP1) (CADR P1)) (- (CAR OP1) (CAR P1)) 0.5) )(SETQ TS (+ TS SS))(SETQ X NIL))))(SETQ S0 (ABS TS))(SETQ TSS (RTOS S0 2 PRE3))(SETV AR "OSMODE" 0)(INITGET 1)(SETQ W (GETPOINT "\nINPUT TEXT POSITION:"))(COMMAND "TEXT" W H 0.0 (STRCAT "S=" TSS)))(DEFUN ETP ()(SETQ X T)(WHILE X(PROMPT "\nSELECT EDGE OF THE POL YGON:")(SETQ S_SET (SSGET))(IF (= S_SET NIL)(PROMPT "\nINV ALID SELECTION, RESELECT PLEASE!")(SETQ X NIL)))(CA_AREA))(DEFUN LTP ()(INITGET 1)(SETQ URC (GETCORNER(SETQ DLC (GETPOINT "\nENTER FIRST CORNER:"))"\nTHE SECOND CORNER:"))(SETQ SSET (SSGET "W" DLC URC))(COND((OR (= ENTP "LINE") (= ENTP "ARC"))(COMMAND "PEDIT" (SSGET P10) "Y" "J" SSET "" "X"))((= ENTP "POL YLINE")(COMMAND "PEDIT" (SSGET P10) "J" SSET "" "X"))(T (PROMPT "\nINV ALID ENTITY FOR PEDIT!"))))(DEFUN RETP ()(SETQ SET1 (SSGET P10))(SETQ ENAME (SSNAME SET1 0))(SETQ ELIST (ENTGET ENAME))(SETQ ENTP (CDR (ASSOC 0 ELIST))))(DEFUN PLTP ()(SETQ ENTP2 (CDR (ASSOC 70 ELIST))))(DEFUN PLS ()(PLTP)(IF (= ENTP2 1)(PROGN (REDRAW ENAME 3)(PROMPT "\nIT'S A CLOSED POL YLINE")(S))(PROGN(REDRAW ENAME 3)(PROMPT "\nIT'S NOT A CLOSED PLINE, TRY TO CLOSE IT!")(LTP)(RETP)(PLTP)(IF (= ENTP2 1)(PROGN (PROMPT "\nNOW IT HAS BEEN CLOSED!")(S))(PROGN (REDRAW ENAME 3)(SETQ X(GETSTRING(STRCAT"\nCAN'T BE CLOSED AUTOMA TICALL Y, CALCULATE IST AREA?""\n<'Y' FOR YES AND ANY OTHER KEY FOR NO>")))(IF (OR (= X "Y") (= X "y"))(S)(PROMPT "\nTHIS ONE IGNORED, CALCULATE NEXT POL YGON!")))))))(DEFUN S ()(COMMAND "AREA" "E" (SSGET P10))(SETQ SS (GETV AR "AREA"))(SETQ S1 (RTOS SS 2 PRE3))(SETV AR "OSMODE" 0)(INITGET 1)(SETQ PT (GETPOINT "\nINPUT TEXT POSITION:"))(COMMAND "TEXT" PT H 0.0 (STRCAT "S=" S1)))(DEFUN THN ()(IF (/= B0 NIL)(PROGN(SETQ BI (RTOS B0 2 1))(INITGET 6)(SETQB (GETREAL(STRCAT "\nINPUT MAP SCALE FACTOR [1:X*1000]/<" BI ">")))(IF (= B NIL)(SETQ B B0)(SETQ B0 B)))(PROGN(INITGET 7)(SETQ B (GETREAL "\nINPUT MAP SCALE FACTOR [1:X*1000]"))(SETQ B0 B)))(IF (/= CAL0 NIL)(PROGN(SETQ CAL1 (RTOS CAL0 2 1))(INITGET 8)(SETQ CAL2 (GETREAL(STRCAT "\nINPUT TEXT ROTATE ANGLE[d]/<" CAL1 ">")))(IF (= CAL2 NIL)(SETQ CAL (/ (* PI CAL0) 180))(PROGN(SETQ CAL (/ (* PI CAL2) 180))(SETQ CAL0 CAL2))))(PROGN (INITGET 8)(SETQ CAL2 (GETREAL "\nINPUT TEXT ROTATE ANGLE[d]:"))(SETQ CAL (/ (* PI CAL2) 180))(SETQ CAL0 CAL2)))(IF (/= HH0 NIL)(PROGN(SETQ HHI (RTOS HH0 2 1))(INITGET 6)(SETQ HH (GETREAL(STRCAT "\nINPUT TEXT HEIGHT [mm]/<" HHI ">")))(IF (= HH NIL)(SETQ HH HH0)(SETQ HH0 HH)))(PROGN (INITGET 7)(SETQ HH (GETREAL "\nINPUT TEXT HEIGHT [MM]:"))(SETQ HH0 HH)))(SETQ H (* HH B))(IF (= WF NIL)(SETQ WF 1.0))(SETQ WI (* H WF)))(DEFUN PRE1N ()(IF (/= PRE10 NIL)(PROGN (SETQ PRE1I (RTOS PRE10 2 0))(INITGET 4)(SETQPRE1 (GETINT(STRCA T "\nINPUT DECIMAL PLACE FOR X-Y COORDINATE <"PRE1I">:")))(IF (= PRE1 NIL)(SETQ PRE1 PRE10)(SETQ PRE10 PRE1)))(PROGN (INITGET 5)(SETQ PRE1(GETINT "\nINPUT DECIMAL PLACE FOR X-Y COORDINATE:") )(SETQ PRE10 PRE1))))(DEFUN PRE2N ()(IF (/= PRE20 NIL)(PROGN (SETQ PRE2I (RTOS PRE20 2 0))(INITGET 4)(SETQ PRE2 (GETINT(STRCAT "\nINPUT DECIMAL PLACE FOR ELEV ATION <"PRE2I">:")))(IF (= PRE2 NIL)(SETQ PRE2 PRE20)(SETQ PRE20 PRE2)))(PROGN (INITGET 5)(SETQ PRE2(GETINT "\nINPUT DECIMAL PLACE FOR ELEV A TION:"))(SETQ PRE20 PRE2))))(DEFUN PRE3N ()(IF (/= PRE30 NIL)(PROGN (SETQ PRE3I (RTOS PRE30 2 0))(INITGET 4)(SETQ PRE3(GETINT(STRCA T "\nINPUT DECIMAL PLACE FOR AREA IDENTIFICATION <"PRE3I">:")))(IF (= PRE3 NIL)(SETQ PRE3 PRE30)(SETQ PRE30 PRE3)))(PROGN (INITGET 5)(SETQ PRE3(GETINT "\nINPUT DECIMAL PLACE FOR AREA IDENTIFICATION:") )(SETQ PRE30 PRE3))))(DEFUN XYZ ()(THN)(PRE1N)(PRE2N)(SETQ XX T)(WHILE XX(INITGET "Exit Continue")(SETQ ZZ (GETKWORD "\nExit/Continue?/<Continue>"))(COND((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "CORD")(XYLA))(IDPT);;(TEXT_P);; (MAX_XY WI PX PY L)(MAX_XY);; (DRLIN CAL P W L)(DRLIN);; (DRCORD AL01 ALPW H CAL PXPX PYPY)(DRCORD);; (DRELEV AL01 ALPW WE CAL WI PRE2)(DRELEV)))))(DEFUN FIX ()(THN)(PRE1N)(PRE2N)(SETQ XX2 T)(WHILE XX2(SETQ XX3 NIL)(IDPT)(ALN1)(SETQ XX T)(WHILE XX(INITGET "Help Exit COntinue CHangepar")(SETQ ZZ (GETKWORD "\nHelp/Exit/COntinue/CHangepar?/<COntinue>"))(COND((= ZZ "Help")(TEXTPAGE)(PROMPT"\n ENTER A V ALUE OR A POINT TO DEFINE THE LENGTH OF OBLIQUAL BASELINE AND")(PROMPT"\nENTER A POINT IN ONE OF THE FOUR QAUDRANTS TO SELECT THE DIRECTION OF THE ")(PROMPT"\nOBLIQUAL BASELINE OR PRESS 'ENTER' TO SELECT THE DEFAULT V ALUES."))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NILXX2 NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "CORD")(XYLA))(IF (= XX3 T)(IDPT))(SETQ XX3 T)(CPXY)(ALN2)(TBL)(CORD)(DE))((= ZZ "CHangepar") (SETQ XX NIL))))))(DEFUN AE ()(ELA)(THN)(PRE2N)(SETQ XX T)(WHILE XX(INITGET "Help Exit Continue")(SETQ ZZ (GETKWORD "\nHelp/Exit/Continue?/<Continue>"))((= ZZ "Help")(TEXTPAGE)(PROMPT"\n FIRST SELECT THE ID POINT, THEN SELECT THE END OF THE")(PROMPT "\nHORIZONTAL BASELINE;"))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETV AR "OSMODE" 1)(SETQ PP (GETPOINT "\nSELECT THE ID POINT:"))(SETQ P (OSNAP PP "END"))(SETQ PXX (CAR P))(SETQ X T)(WHILE X(SETQ WEE (GETPOINT "\nINPUT THE TEXT POSITION:"))(SETQ WE (OSNAP WEE "END"))(IF (= WE NIL)(PROMPT "\nINV ALID POSITION, RESELECT PLEASE!")(SETQ X NIL)))(SETQ WX (CAR WE))(SETV AR "OSMODE" 0)(DE)))))(DEFUN PLGS ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(ETP)(SETV AR "osmode" 0)(SETQ PT (GETPOINT "\n Please input TEXT POSITION:")) (COMMAND "text"PTH0.0(STRCAT "S=" S_AREA)))(DEFUN CA_AREA ()(SETQ ENT_NAME (SSNAME S_SET 0))(SETQ ENT_NUM (SSLENGTH S_SET))(SETQ T_AREA 0LOOP 0NUM 0)(WHILE LOOP(COMMAND "AREA" "E" ENT_NAME)(SETQ S1_AREA (LIST (GETV AR "AREA")))(SETQ S2_AREA (CAR S1_AREA))(SETQ T_AREA (+ T_AREA S2_AREA))(SETQ NUM (+ NUM 1))(SETQ ENT_NAME (SSNAME S_SET NUM))(IF (= NUM ENT_NUM)(SETQ LOOP NIL)))(SETQ S_AREA (RTOS T_AREA 2 PRE3)))(DEFUN E_LAYER ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(SETQ L_NAME (GETSTRING "\nPlaese input LAYER NAME:")) (SETQ S_SET (SSGET "X"(LIST (CONS 0 "POL YLINE")(CONS 8 L_NAME))))(CA_AREA)(SETV AR "osmode" 0)(INITGET 1)(SETQ PT (GETPOINT "\n Please input TEXT POSITION:")) (COMMAND "text"PTH0.0(STRCAT "The layer<" L_NAME ">S=" S_AREA)))(DEFUN E_COLOR ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(SETQ C_NAME (GETINT "\nPlaese input COLOR NAME:")) (SETQ S_SET (SSGET "X"(LIST (CONS 0 "POL YLINE")(CONS 62 C_NAME))))(CA_AREA)(SETV AR "osmode" 0)(INITGET 1)(SETQ PT (GETPOINT "\n Please input TEXT POSITION:")) (COMMAND "text"PTH0.0(STRCAT "The color <" (RTOS C_NAME 2 0) ">S=" S_AREA) ))(DEFUN POS ()(SETQ CLA (GETV AR "CLAYER"))(IF (/= CLA "AREA")(SLA))(THN)(PRE3N)(SETQ XX T)(WHILE XX(INITGET "Help Exit Continue")(SETQ ZZ (GETKWORD "\nHelp/Exit/Continue?/<Continue>"))(COND((= ZZ "Help")(TEXTPAGE)(PROMPT"\n ENTER THE POINTS TO DEFINE THE EDGE OF THE REGION")(PROMPT"\nTO BE CALCULATED AND IDed, AFTER LAST POINT ENTERED,")(PROMPT"\nPRESS 'ENTER' AND THEN SELECT A POINT TO DEFINE THE")(PROMPT "\nPOSITION OF THE AREA ID TEXT."))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(PCR)))))(DEFUN XYLA ()(COMMAND "LAYER" "M" "CORD" "C" "CYAN" "" ""))(DEFUN ELA ()(COMMAND "LAYER" "M" "ELEV" "C" "CYAN" "" ""))(DEFUN SLA ()(COMMAND "LAYER" "M" "AREA" "C" "CYAN" "" ""))(DEFUN ALN1 ()(IF (/= AL0 NIL)(PROGN (SETQ ALI (RTOS AL0 2 1))(INITGET 70)(PROMPT(STRCAT "\nINPUT OBLIQUAL LINE LENGTH [DRAWING UNIT]/<"ALI">:"))(SETQ ALL (GETDIST P))(IF (= ALL NIL)(SETQ ALL AL0)(SETQ AL0 ALL)))(PROGN (INITGET 71)(SETQ ALL (GETDIST P"\nINPUT OBLIQUAL LINE LENGTH [DRAWING UNIT]"))(SETQ AL0 ALL)))(IF (/= WA0 NIL)(PROGN(SETQ WAI (ANGTOS W A0 0 0))(PROMPT(STRCAT "\nCHOOSE THE DIRECTION OF THE OBLIQUAL LINE<"WAI"d>:"))(SETQ DRL (GETANGLE P))(IF (= DRL NIL)(SETQ W A WA0)(PROGN(COND((< DRL (* PI 0.5))(SETQ W A (* PI 0.25)))((< DRL PI)(SETQ W A (* PI 0.75)))((< DRL (* PI 1.5))(SETQ W A (* PI 1.25)))((< DRL (* PI 2.0))(SETQ W A (* PI 1.75)))))))(PROGN (INITGET 1)(SETQDRL (GETANGLE P"\nCHOOSE THE DIRECTION OF THE OBLIQUAL LINE:"))(COND((< DRL (* PI 0.5))(SETQ WA (* PI 0.25)))((< DRL PI)(SETQ WA (* PI 0.75)))((< DRL (* PI 1.5))(SETQ WA (* PI 1.25)))((< DRL (* PI 2.0))(SETQ WA (* PI 1.75))))(SETQ WA0 WA))))(DEFUN ALN2 ()(SETQ W (POLAR P (+ CAL WA) ALL))(SETQ WX (CAR W)))(DEFUN TSET ()(SETV AR "FILEDIA" 0)(SETQ WFF (GETREAL"\nINPUT THE WIDTH-HEIGHT FACTOR OF TEXT<1.0>:"))(IF (= WFF NIL)(SETQ WF 1.0))(COMMAND "STYLE" "STANDARD" "MONOTXT" "0.0" WF "0" "N" "N" "N") (SETV AR "FILEDIA" 1)(COMMAND "COLOR" "BYLAYER")(PRINC))(DEFUN CO-ZOOM ()(PROMPT "\nTURN OFF ALL UNCONCERN LAYERS!")(IF (/= CS0 NIL)(PROGN (SETQ CSI (RTOS CS0 2 1))(INITGET 6)(PROMPT (STRCAT "\nINPUT CURRENT SCALE FACTOR<" CSI ">:"))(SETQ CS (GETREAL))(IF (= CS NIL)(SETQ CS CS0)(SETQ CS0 CS)))(PROGN (SETQ CS (GETREAL "\nINPUT CURRENT SCALE FACTOR:")) (SETQ CS0 CS)))(IF (/= DS0 NIL)(PROGN (SETQ DSI (RTOS DS0 2 1))(INITGET 6)(PROMPT (STRCAT "\nINPUT PREFER SCALE FACTOR<" DSI ">:"))(SETQ DS (GETREAL))(IF (= DS NIL)(SETQ DS DS0)(SETQ DS0 DS)))(PROGN (SETQ DS (GETREAL "\nINPUT PREFER SCALE FACTOR:")) (SETQ DS0 DS)))(SETQ FTOR (/ DS CS))(SETQ XX T)(WHILE XX(INITGET "Help Exit Continue")(SETQ ZZ (GETKWORD "\nHelp/Exit/Continue?/<Continue>"))(COND((= ZZ "Help")(TEXTPAGE))((= ZZ "Exit")(PROMPT "\nEXIT TO MAIN SELECTIONS")(SETQ XX NIL)(PRINC))((OR (= ZZ NIL) (= ZZ "Continue"))(SETV AR "OSMODE" 32)(INITGET 1)(SETQ P (GETPOINT "\SELECT THE ID BASELINE:"))(SETQ PP (OSNAP P "END,INS"))(SETQ P2 (GETCORNER(SETQ P1 (GETPOINT "\nSELECT TEXTs IN WINDOW:"))))(SETQ SSET (SSGET "W" P1 P2))(COMMAND "SCALE" SSET "" PP FTOR)))))(DEFUN HLP ()(PROMPT "\n"))(defun-q *error* () ("PROGRAM TERMINA TED BY USER")(PRINC "\nERROR: ")(PRINC "PROGRAM TERMINA TED BY USER!")(PRINC))(DEFUN C:DM ()(PRINC)(SETQ CULA (GETV AR "CLAYER"))(SETQ XXX T)(SETQ ZP "3d")(WHILE XXX(INITGET"Help Set 3D F3d Ae APOint APLine ALayer AColor Coz Exit")(SETQZ (GETKWORD"\nHelp/Set/3D/F3d/Ae/APOint/APLine/ALayer/AColor/Coz/Exit:"))(SETQ ZP1 Z)(IF (= Z NIL)(SETQ Z ZP))(SETQ ZP ZP1)(COND((= Z "Help") (HLP))((= Z "Set") (TSET))((= Z "3D") (XYZ))((= Z "F3d") (FIX))((= Z "APOint") (POS))((= Z "APLine") (PLGS))((= Z "ALayer") (E_LAYER))((= Z "AColor") (E_COLOR))((= Z "Coz") (CO-ZOOM))((= Z "Ae") (AE))((= Z "Exit")(COMMAND "LAYER" "S" CULA "")(PROMPT "\n *** Exit from DM program, Thanks! ***")(SETQ XXX NIL))))(PRINC))。
AutoCADlisp插件三维交点坐标提取
;;;本插件为AutoCADlisp插件,用于获取LINE命令绘出的线段的交点,交点坐标返回为被交线段上的点(即外观交点xy+被交线段对应该点的z值);;;获取切割线与相交直线的交点,返回被交线段上的交点。
(defun C:JDHQ()(setvar "cmdecho" 0)(princ "\n选择要切割的直线:")(setq lll(entsel));选择直线;;;;取得直线起点零高程坐标列表(setq lllxyz1(cdr (assoc 10 (entget (car lll)))))(setq lllx1(nth 1 lllxyz1))(setq llly1(nth 0 lllxyz1))(setq lllxyz10 (list llly1 lllx1 0.0));;;;取得直线终点零高程坐标列表(setq lllxyz2(cdr(assoc 11 (entget (car lll)))))(setq lllx2(nth 1 lllxyz2))(setq llly2(nth 0 lllxyz2))(setq lllxyz20 (list llly2 lllx2 0.0));;;(princ "\n选择被相交的直线图元集:")(setq ss(ssget));被交线图元集(setq n(sslength ss));计算图元集图元个数(setq ff(open(getfiled "交点保存为" "" "txt" 1)"w"));;;;;(setq i 0)(repeat n(setq spt (ssname ss i))(setq ept (entget spt))(if (=(cdr(assoc 0 ept)) "LINE")(progn(setq lxyz1(cdr (assoc 10 ept)))(setq sx1(nth 1 lxyz1))(setq sy1(nth 0 lxyz1))(setq sz1(nth 2 lxyz1))(setq lxyz10 (list sy1 sx1 0.0));;;(setq lxyz2(cdr (assoc 11 ept)))(setq sx2(nth 1 lxyz2))(setq sy2(nth 0 lxyz2))(setq sz2(nth 2 lxyz2))(setq lxyz20 (list sy2 sx2 0.0));;;;计算交点坐标(setq jdxy0(inters lllxyz10 lllxyz20 lxyz10 lxyz20))(if (/= jdxy0 nil)(progn(setq jdx(nth 1 jdxy0))(setq jdy(nth 0 jdxy0));;求交点高程z(setq l1(sqrt(+(* (- sx2 sx1) (- sx2 sx1)) (* (- sy2 sy1) (- sy2 sy1)))))(setq l2(sqrt(+(* (- jdx sx1) (- jdx sx1)) (* (- jdy sy1) (- jdy sy1)))))(setq jdz(+ sz1 (* (- sz2 sz1) (/ l2 l1))))(setq jdz1(rtos jdz 2 3))(setq jdx1(rtos jdx 2 3))(setq jdy1(rtos jdy 2 3));;(setq jdxyz(strcat jdy1"," jdx1 ","jdz1))(write-line jdxyz ff)))))(setq i (+ i 1)))(close ff)(prin1))(prompt "********<<C:JDHQ>>********")(prin1)。
五个实用的AutoCAD的lisp程序
五个实用的AutoCAD的lisp程序1、计算CAD图形中所有线段总长度(加载后只需框选所有线段便可得出这些线段的总长度)(defun c:LL ()(setvar "cmdecho" 1)(setq en (ssget (list '(0 . "spline,arc,line,ellipse,LWPOLYLINE"))))(setq i 0)(setq ll 0)(repeat (sslength en)(setq ss (ssname en i))(setq endata (entget ss))(command "lengthen" ss "")(setq dd (getvar "perimeter"))(setq ll (+ dd ll))(setq i (1+ i)))(princ "所选线条总长为:")(princ ll)(princ))2、标注CAD图形中所有线段(加载后只需框选所有线段便可得标注这些线段)(defun c:LLL ()(COMMAND "UCS" "")(setvar "cmdecho" 1)(SETVAR "OSMODE" 0)(setq AcadObject (vlax-get-acad-object)AcadDocument (vla-get-ActiveDocument Acadobject)mSpace (vla-get-ModelSpace Acaddocument));;选取需要测量的样条曲线、圆弧、直线、椭圆(setq en (ssget (list '(0 . "spline,arc,line,ellipse,LWPOLYLINE"))))(setq i 0);;获取系统参数textsize(setq shh (getvar "textsize"))(setq str_hh (strcat "\n文字高度 <" (rtos shh 2) ">: "))(setq hh (getdist str_hh))(while hh(setvar "textsize" hh)(setq hh nil));;输入标注文字高度;;循环开始(repeat (sslength en)(setq ss (ssname en i))(setq endata (entget ss))(command "lengthen" ss "")(setq dd (getvar "perimeter"))(princ (strcat "\n长度=" (rtos dd 2)));;寻找代表图层的字符串(setq aa (assoc 0 endata));;获取图层名称(setq aa1 (cdr aa));;判断线条种类(cond((= aa1 "SPLINE");;如果是spline(progn(setq arcObj (VLAX-ENAME->VLA-OBJECT ss))(setq startPnt1 (vla-get-ControlPoints arcObj))(setq p1(vlax-safearray->list (vlax-variant-value startPnt1)) )(setq x1 (car p1))(setq y1 (cadr p1))(setq z1 (caddr p1))(setq pp1 (list x1 y1 z1))(repeat (- (/ (length p1) 3) 1);;循环,寻找最后一个控制点(setq p1 (cdddr p1))(setq x2 (car p1))(setq y2 (cadr p1))(setq z2 (caddr p1)))(setq pp2 (list x2 y2 z2))))((= aa1 "LWPOLYLINE");;如果是LWPOLYLINE(progn(setq arcObj (VLAX-ENAME->VLA-OBJECT ss)) (setq startPnt1 (vla-get-Coordinates arcObj)) (setq p1(vlax-safearray->list (vlax-variant-value startPnt1)) )(setq x1 (car p1))(setq y1 (cadr p1))(setq z1 (caddr p1))(setq pp1 (list x1 y1 z1))(repeat (- (/ (length p1) 3) 1);;循环,寻找最后一个控制点(setq p1 (cdddr p1))(setq x2 (car p1))(setq y2 (cadr p1))(setq z2 (caddr p1)))(setq pp2 (list x2 y2 z2))))(t;;如果是其他种类线条(progn(setq arcObj (VLAX-ENAME->VLA-OBJECT ss)) (setq startPnt1 (vla-get-StartPoint arcObj));;获取起点(setq endPnt1 (vla-get-EndPoint arcObj));;获取终点(setq pp1(vlax-safearray->list (vlax-variant-value startPnt1)))(setqpp2 (vlax-safearray->list (vlax-variant-value endPnt1)) ))))(setq x1 (car pp1))(setq y1 (cadr pp1))(setq z1 (caddr pp1))(setq x2 (car pp2))(setq y2 (cadr pp2))(setq z2 (caddr pp2))(setq x (/ (+ x1 x2) 2))(setq y (/ (+ y1 y2) 2))(setq z (/ (+ z1 z2) 2))(setq pt (list x y z));;取得线段两端的中点(setq ang (angle pp1 pp2));;获取角度(if (> (* (/ ang pi) 180) 180)(setq ang (+ ang pi)))(command "text""j""bc"pt""(* (/ ang pi) 180)(strcat "" (rtos dd 2))"")(setq i (1+ i)))(prin1))(prompt "\n <>在图中直接写出长度") (prin1)3、连续打断程序(defun c:br1 ()(command "break" pause "f" pause "@"))4、将CAD文字导入Excel表格(defun c:Q2()(setq ffn (getfiled "写出文件" "" "xls" 1))(princ "\n选取文字...")(setq ss (ssget))(setq ff (open ffn "w"))(setq i 0)(repeat (sslength ss)(setq ssn (ssname ss i))(setq ssdata (entget ssn))(setq sstyp (cdr (assoc 0 ssdata)))(if (or (= sstyp "TEXT") (= sstyp "MTEXT"))(progn(setq txt (cdr (assoc 1 ssdata)))(princ txt ff)(princ "\n" ff)))(setq i (1+ i)))(close ff)(princ (strcat "\n写出文件: " ffn))(prin1))5、删除带颜色图元以下程序在别人的贴子里贴过.为了说明问题,今天再贴一次。
单曲线坐标计算并展点用CAD_lisp函数
结果: K25+650.926 X=3252647.051 Y=381399.471 A=166.566509 度
输入下一个桩号[放弃(-1)]:25690
结果: K25+690 X=3252609.1001 Y=381408.771 A=165.866009 度
(9)输入下一个桩号[放弃(-1)] :停止连续桩号计算时,输入-1即可退出命令
注意事项:本开发使用辛卜生公式,故参数的使用需符合辛卜生公式要求。按桩号递减方向计算坐标时需调整曲线始点的角度值=方位角±180度!
如A->B曲线桩号递增,B点方位角为166度,按B->A桩号递减方向计算时,B点的方位角应为166+180=246度。
输入下一个桩号[放弃(-1)]:-1
命令:
选择顺曲线桩号递增方向的转向[左(-1)\右(1)]:-1
-------------------------------------------------------------
开始桩号坐标计算,请输入曲线始点至终点间的桩号!
-------------------------------------------------------------
(6)输入曲线终点半径(半径=∞时为0) :半径无穷大时(接直线),曲率趋向0,内有判断机制,故录入0
(ቤተ መጻሕፍቲ ባይዱ)选择顺曲线桩号递增方向的转向[左(-1)\\右(1)] :左转录入-1 ,右转录入1不要录入其他数据。
(8)输入桩号[自动序列(-2)]: :输入-2即可进行自动序列计算
使用示例:本示例为CAD命令行回显信息:
LISP程序课件
• • • • • • • • • • •
\\ 表示字符 ”\” \” 表示字符 “” “ \r 表示回车 \n 表示换行 \nnn 表示八进制代码为nnn的ASCII字符 字符串常数的最大长度为100,但赋给一个符号的字符串长度没有这个限制。 下列都是合法的字符串 “\nEnter first point:” 注意换行的写法 “ABC\”D” 注意字符串中含“的写 法 “c:\\Autocad2000\\FONTS\\TEXT.SHX” 注意目录的写法 “” 空串 2.1.4 符号
• • • •
•
• • • • • •
2.1 AutoLISP的数据类型 整型(INT)、实型(REAL)、字符型(STR)、符号(SYM)、表(LIST)、内部函数 (SUBR)、文件描述符(FILE)、实体名(ENAME)、选择集(PICKSET)、函数分 页表(PAGETB)、VLA对象(Visual Lisp Activex)。 2.1.1整型 整数由数字组成,不包含小数点。AutoLISP 的整数是 32 位带符号的数,取 值范围从 +2,147,483,647 到 -2,147,483,648(注意,getint 函数只接受 16 位的数,即 +32767 到 -32678)。当用户在 AutoLISP 表达式中直接使用整 数时,该值被称为常量。数字 2、-56 和 1,200,196 都是有效的 AutoLISP 整 数。 如果输入的数超出了允许的最大整数(导致整数溢出),AutoLISP 会将整数 转换为实数。然而,如果对两个有效整数执行算术运算,其结果超出了允许 的最大整数,得出的数是无效的。下面样例说明 AutoLISP 如何处理整数溢 出。 最大的正整数保留其值: _$ 2147483647 2147483647 如果输入一个大于允许最大值的整数,AutoLISP 将其值返回为实数: _$ 2147483648 2.14748e+009
坐标提取lisp程序
坐标提取l i s p程序(共22页) -本页仅作为预览文档封面,使用时请删除本页-坐标提取lisp程序2010-05-17 20:50:07| 分类:工程 | 标签: |字号大中小订阅;该程序主要用于CAD点(point)三维坐标提取,并将数据输出为CASS软件中使用的数据格式;输出格式:点号,,测量Y值,测量X值,测量Z值例:1,,,1232,433,25;2010-05-17 ;命令:plzbsc(defun c:plzbsc() (princ "\n选择所需输出的点(point):") (setq ss (ssget ));;选取坐标点(setq n (sslength ss ));计算坐标点数量 (setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径(setq i 0) (repeat n (setq spt (ssname ss i )) (setq ept (entget spt)) (if (= (cdr (assoc 0 ept))"POINT") (progn(setq lxyz (cdr (assoc 10 ept))) (setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符(setq sy (rtos (nth 0 lxyz))) (setq sz (rtos (nth 2 lxyz))) (setq i1 (+ i 1));计算点序号 (setq sn (rtos i1 2 0));将序号实数转换成字符(setq sxyz (strcat sn",," sy"," sx "," sz)) (write-line sxyz ff) ) ) (setq i (+ i 1)) );repeat )(prompt "* << 命令:plzbsc >> *输出格式(点号,, Y,X,Z)**")(prin1)地形图上提取碎步点(高程点)坐标并输出到文本2010-05-18 08:50:38| 分类:工程 | 标签: |字号大中小订阅利用程序提取地形图上碎步点的三维坐标。
基于AUTO-LISP实现CAD中批量提取坐标的研究
基于 AUTO-LISP实现 CAD中批量提取坐标的研究摘要:在工程设计与施工放样的过程中,经常需要提取点位的设计坐标,一般是利AutoCAD的坐标查询功能,在屏幕上逐个捕捉放样点,使其坐标显示在命令行中,然后手工抄录或者复制到电子文档上,速度很慢。
如果AutoCAD在遇到批量提取坐标时,只有通过二次开发才能满足,AutoCAD二次开发的手段很多,如:C++、Java、VB、LISP等。
本文以提取四期筒仓桩基坐标为例,尝试利用Auto-lisp编程工具开发程序,实现CAD中自动批量提取放样点坐标的目的。
关键词:Auto-lisp;CAD二次开发;坐标提取;编程。
1 引言在工程设计与施工放样的过程中,经常需要提取点位的设计坐标,以便进行校核与施工放样,一般是利用AutoCAD的坐标查询功能,在屏幕上逐个捕捉放样点,使其坐标显示在命令行中,然后手工抄录或者复制到电子文档上,速度很慢。
如果AutoCAD在遇到批量提取坐标时这种命令就更显得力不从心了,这时需要二次开发才能满足,AutoCAD二次开发的手段很多,如:C++、Java、VB、LISP等。
本文以提取四期筒仓桩基坐标为例,尝试利用Auto-lisp编程工具开发程序,实现CAD中自动批量提取放样点坐标的目的。
2 Auto-lisp 简介Auto-lisp是一种针对扩充及自订AutoCAD函数机能而产生,以LISP为基础的程序设计语言,目的是令使用者充份利用AutoCAD进行开发,直接增加及修改AutoCAD指令, AutoLisp语言建基于普通的LISP语言上,并扩充了许多适用于CAD的特殊功能而形成,是一种能以直译方式(不须先行编译)亦可于AutoCAD内部执行的直译性程序语言,程序容易学习及撰写,程序即使出错亦不会对操作系统(如DOS,WINDOWS)有不良影响,数据及程序均统一以串行 (List)结构表示,可直接调用几乎全部的AutoCAD命令,既具备一般高级语言的基本结构和功能,亦有一般高级语言没有的强大图形处理能力,内建于AutoCAD应用程序,不须另行购买,亦不须使用特定的编辑器或开发环境。
坐标转换参数求取及坐标转换程序设计
坐标转换参数求取及坐标转换程序设计坐标转换是一种将一个坐标系统中的点转换为另一个坐标系统中的点的过程。
在现实生活中,常常需要将一个点的位置从一个坐标系转换到另一个坐标系,比如将经纬度坐标转换为地图坐标,将平面坐标转换为三维坐标等等。
坐标转换参数求取是指根据已知的转换点的坐标,推导出坐标转换的数学公式或参数。
根据不同的坐标转换需求,可能需要求解不同的参数。
比如,要将经纬度坐标转换为地图坐标,常用的参数有缩放系数、平移系数和旋转角度等。
坐标转换程序设计是指根据已知的坐标转换参数,设计出一个能够实现坐标转换功能的计算机程序或算法。
在设计程序时,需要考虑如何输入和输出坐标数据,如何进行算法实现和优化,以及如何进行错误处理等等。
下面以将经纬度坐标转换为地图坐标为例,介绍坐标转换参数求取及坐标转换程序设计的步骤:1.确定坐标转换的数学模型:经纬度坐标转换为地图坐标常用的数学模型是仿射变换或投影变换。
根据实际需求和转换的精度要求,选择适合的数学模型。
2.收集转换点的坐标数据:选择多个已知的经纬度和地图坐标点进行测量,得到它们在两个坐标系中的坐标数据。
3.利用已知坐标数据求取转换参数:根据数学模型的不同,可以采用不同的方法求取转换参数。
常用的方法有最小二乘法、最大似然估计等。
利用已知的经纬度和地图坐标点,求解出转换参数。
4.设计坐标转换程序:根据所求得的转换参数,设计一个能够实现经纬度到地图坐标转换的程序。
程序的输入可以是经纬度坐标点,输出是地图坐标点。
5.实现程序并进行测试:根据所设计的程序和算法,利用已知的转换点进行测试,验证程序的正确性和精度。
在进行坐标转换参数求取及坐标转换程序设计时1.坐标系的选择:根据实际应用需求,选择合适的坐标系。
不同的坐标系有不同的数学模型和坐标转换参数。
2.数学模型的选择:根据转换的精度要求和应用场景,选择适合的数学模型。
不同的数学模型有不同的转换参数求取方法。
3.数据的准确性和可靠性:收集的已知坐标数据应该具有一定的准确性和可靠性,以确保所求取的转换参数能够有效地进行坐标转换。
Lisp应用于坐标标注中若干问题解析
Lisp应用于坐标标注中的若干问题解析摘要:随着cad的广泛应用,设计师们对cad的要求也越来越高。
通过二次开发工具lisp语言能够很好地解决日常工作中的许多小型问题。
坐标标注这一程序在设计过程中,要充分考虑到图层、捕捉、坐标取位精度和引线位置计算等方面的问题,切实做到程序正确实用、操作方便、不破坏原图的参数环境,使cad不仅是绘图工具,同时也是得心应手的高效设计平台。
关键词:图层捕捉控制取位精度引线方向加载autocad软件应用已经在建筑设计、城市规划、工程制图、机械设计、电子电路等单位普及,它为我们的工作带来了很大的便利。
随着工作的不断细化,广大设计师对cad的要求也在不断地增强,有些工作中需要的功能,在cad软件中并没有提供,需要通过二次开发的功能来实现。
autocad二次开发的主要工具有lisp、vb/vba 的activex及c/c++的objectarx。
lisp以其简单、易于掌握的特点深受设计师的喜爱。
lisp语言是人工智能学科领域中广泛采用的一种程序设计符号语言,这种语言在参数化绘图中有很大的灵活性。
lisp开发出的程序可以像运行cad普通命令一样在命令行中直接键入自己定义的命令运行,保持了用户的绘图习惯。
在设计中我们经常会遇到对图纸上的坐标进行标注的问题。
对于市面上的专业软件如cass软件、天正软件均具有该项功能,但对于广大设计师,他们使用的是普通cad而非专业版的,并不具备这一功能,需要通过lisp语言进行二次开发来实现。
一个好的lisp程序至少要保证三个条件:1、程序本身运行的正确性2、程序操作简单、界面清晰3、程序执行完后要还原所有改动过的cad运行环境参数。
因此在编写坐标标注这一程序时要考虑以下相关问题。
一、图层控制程序执行所生成的坐标标注信息应该放在同一层内(如zbbz 层),且不应破坏原有图层,这样便于对zbbz这一层进行开、关、冻结、删除等层控操制。
首先用(setq old-layer (getvar “clayer”))命令将程序执行前的当前图层名提取出来存入old-layer这个变量。
getpl坐标提取
getpl坐标提取摘要:1.介绍getpl 坐标提取工具2.getpl 坐标提取工具的使用方法3.getpl 坐标提取工具的优势和应用场景4.总结正文:1.介绍getpl 坐标提取工具getpl 坐标提取是一款功能强大的坐标提取工具,可以快速、准确地从图片中提取出所需的坐标信息。
该工具基于先进的计算机视觉技术,结合了深度学习和图像处理等多种技术,能够满足各种不同场景下的坐标提取需求。
2.getpl 坐标提取工具的使用方法getpl 坐标提取工具的使用方法非常简单。
用户只需上传需要提取坐标的图片,工具会自动对图片进行分析,识别出其中的坐标信息,并将提取的结果以文本或Excel 等格式导出。
具体操作步骤如下:(1)上传图片:用户可以通过点击“选择文件”按钮,上传需要提取坐标的图片。
(2)分析图片:工具会自动对上传的图片进行分析,识别出其中的坐标信息。
(3)查看结果:分析完成后,用户可以在结果页面查看提取的坐标信息,并可以选择导出结果。
3.getpl 坐标提取工具的优势和应用场景getpl 坐标提取工具具有以下优势:(1)准确性高:基于深度学习和图像处理技术,能够准确识别出图片中的坐标信息。
(2)速度快:处理速度快,用户可以快速得到提取结果。
(3)操作简单:用户只需上传图片,即可轻松提取坐标信息。
该工具广泛应用于地图制作、地理信息系统(GIS)、遥感图像处理、物流跟踪等领域,帮助用户快速、准确地提取图片中的坐标信息,提高工作效率。
4.总结getpl 坐标提取工具是一款功能强大、操作简单的坐标提取工具,可以满足各种不同场景下的坐标提取需求。
getpl坐标提取
getpl坐标提取1. 任务概述在地理信息系统(GIS)中,坐标提取是一个常见的任务。
getpl坐标提取是指从一个getpl文件中提取出所有的坐标信息。
getpl文件是一种常见的地理数据文件格式,其中包含有关点、线和面的几何坐标信息。
本文将介绍getpl坐标提取的背景和意义,详细说明如何使用Python编写一个能够从getpl文件中提取坐标的程序。
同时,还将提供一些示例代码和演示如何处理不同类型的getpl文件。
2. 背景和意义在GIS领域,地理坐标是描述地球上某一点位置的数学方法。
通过获取地理坐标,我们可以准确地表示和定位地理空间中的点、线和面。
而getpl文件是一种常见的地理数据文件格式,广泛用于GIS软件中存储和传输地理数据。
getpl文件通常包含了大量的坐标信息,这些坐标信息可以用于绘制地图、进行空间分析和模拟等。
因此,对于GIS从业者和研究人员来说,从getpl文件中提取坐标是一项非常重要的任务。
3. 坐标提取的步骤要从getpl文件中提取坐标,可以按照以下步骤进行:步骤1:读取getpl文件首先,需要使用Python中的文件读取函数打开getpl文件,并将其读入内存中。
可以使用Python的内置函数open()来打开文件,并使用readlines()函数逐行读取文件内容。
with open('getpl_file.getpl', 'r') as file:lines = file.readlines()步骤2:解析坐标信息在getpl文件中,每一行通常表示一个点、线或面的坐标信息。
可以通过解析每一行的内容,提取出其中的坐标信息。
对于点,坐标信息通常以(x, y)的形式表示。
可以使用正则表达式来匹配这种形式的坐标,并提取出其中的x和y值。
对于线和面,坐标信息通常以一系列点的形式表示。
可以使用正则表达式匹配以[(x1, y1), (x2, y2), ...]的形式表示的坐标信息,并提取出其中的每个点的x和y值。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
坐标提取lisp程序2010-05-17 20:50:07| 分类:工程| 标签:|字号大中小订阅;该程序主要用于CAD点(point)三维坐标提取,并将数据输出为CASS软件中使用的数据格式;输出格式:点号,,测量Y值,测量X值,测量Z值例:1,,100.3244,1232,433,25;2010-05-17;命令:plzbsc(defun c:plzbsc()(princ "\n选择所需输出的点(point):")(setq ss (ssget ));;选取坐标点(setq n (sslength ss ));计算坐标点数量(setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径(setq i 0)(repeat n(setq spt (ssname ss i ))(setq ept (entget spt))(if (= (cdr (assoc 0 ept)) "POINT")(progn(setq lxyz (cdr (assoc 10 ept)))(setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符(setq sy (rtos (nth 0 lxyz)))(setq sz (rtos (nth 2 lxyz)))(setq i1 (+ i 1));计算点序号(setq sn (rtos i1 2 0));将序号实数转换成字符(setq sxyz (strcat sn",," sy "," sx "," sz))(write-line sxyz ff)))(setq i (+ i 1)));repeat)(prompt "* << 命令:plzbsc >> *输出格式(点号,, Y,X,Z)**")(prin1)地形图上提取碎步点(高程点)坐标并输出到文本2010-05-18 08:50:38| 分类:工程| 标签:|字号大中小订阅利用程序提取地形图上碎步点的三维坐标。
并输出到记事本中,该程序待修改的地方是不能选取点,并输出数据,待改正。
(defun c:gcdtq()(setvar "cmdecho" 0) ;指令执行过程不响应(setq en (entsel "选择高程点:")) ;要求碰选一个高程点(setq ff (open (getfiled "文件保存为" "f:/" "txt" 1) "a"))(setq en_data (entget (car en))) ;取得元体资料列表(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt(setq py(rtos (nth 1 pt)));提取测量坐标Y值(setq px(rtos (nth 0 pt)));提取测量坐标X值(setq pz(rtos (nth 2 pt)));提取测量坐标Z值(setq sxyz (strcat px " " py " " pz))(write-line sxyz ff)(prin1))(prompt "*************** << C:gcdtq >> *****************")(prin1)连续选取高程点并输出到文本2010-05-18 15:33:49| 分类:工程| 标签:|字号大中小订阅;2010-05-18 武赤公路;用于提取地形图中的高程点(碎步点)坐标,同时可以提取点(point)的坐标;本程序的缺点是不能过滤对象,同时也成为了他的优点;没有限制点的样式,块也可以,点也可以;;本程序设计保存文件是可以在已有文件中继续添加数据,但是序号不再累积;这样可以判断不同时期选取的数据(defun c:gcdtq()(setvar "cmdecho" 0) ;指令执行过程不响应(setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "a"))(setq en (entsel "选择高程点:"));要求碰选一个高程点(setq i 1);生成序号(while en(setq en_data (entget (car en))) ;取得元体资料列表(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt(setq py(rtos (nth 1 pt)));提取测量坐标系Y值(setq px(rtos (nth 0 pt)));提取测量坐标洗X值(setq pz(rtos (nth 2 pt)));提取测量坐标系Z值(setq pi(rtos i 2 0))(setq pxyz (strcat pi",," px "," py "," pz));输出为CASS数据格式(write-line pxyz ff);写入文本(setq en (entsel "\n选择下一个高程点<回车结束选择>:"))(setq i (+ i 1)))(close file)(prin1))(prompt "**从CASS中提取高程点或(point)点坐标,* << C:gcdtq >> *高程点提取**") (prin1)横断面数据提取(待修改)2010-05-18 21:59:09| 分类:工程| 标签:|字号大中小订阅(defun c:hdm()(setvar "cmdecho" 0) ;指令执行过程不响应;计算方位角(setq ff (open (getfiled "文件保存为" "c:/" "hdm" 1) "a"))(setq zh (getreal"请输入桩号:"));计算横断面上点到中心线的垂距,数值分正负(setq pt1 (getpoint "\n拾取纵断面上的一点:"));用于确定横断面上的零点位置(setq x1 (car pt1));给纵断面上一点X赋值x1(setq y1 (cadr pt1));给纵断面上一点Y赋值y1(setq pt2 (getpoint "\n拾取纵断面上的第二点:"));用于确定横断面上的零点位置(setq x2 (car pt2));给纵断面上一点X赋值x1(setq y2 (cadr pt2));给纵断面上一点Y赋值y1;计算纵断面(pt1->pt2)方位角(setq j1 (atan (/(- y2 y1) (+(- x2 x1) 0.00000001)))))(setq j2 (/(* j1 180) pi))(if (>(- y2 y1) 0)(setq sgn 1));符号判断(if (=(- y2 y1) 0)(setq sgn 0))(if (<(- y2 y1) 0)(setq sgn -1))(setq fwj (+ (- 180(* 90 sgn) j2)));方位角计算(setq ang (/(* fwj pi) 180))(setq en (entsel "选择高程点:"));要求碰选一个高程点(while en(setq en_data (entget (car en))) ;取得元体资料列表(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt(setq py (nth 1 pt));提取测量坐标系Y值(setq px (nth 0 pt));提取测量坐标洗X值(setq px2 (sin ang))(setq px3 (cos ang))(setq cj (-(* (- py y1) (cos ang)) (* (- px x1) (sin ang))));计算垂直距离(cj)(setq dist (rtos cj 2 0))(setq pz(rtos (nth 2 pt)));提取测量坐标系Z值(setq pdz (strcat dist","pz));输出为CASS数据格式(write-line pdz ff);写入文本(setq en (entsel "\n选择下一个高程点<回车结束选择>:")))(close file)(prin1))(prompt "**从CASS中提取高程点或(point)点坐标,* << C:hdm >> *输出横断面数据(平距,高程)**") (prin1)批量提取CAD中点(point)三维坐标2010-05-22 23:11:43| 分类:默认分类| 标签:|字号大中小订阅;该程序主要用于CAD点(point)三维坐标提取,并将数据输出为CASS软件中使用的数据格式;输出格式:点号,,测量Y值,测量X值,测量Z值例:1,,100.3244,1232,433,25;2010-05-17 罗泽钢中国葛洲坝集团基础工程有限公司;命令:plzbsc(defun c:plzbsc()(princ "\n选择所需输出的点(point):")(setq ss (ssget ));;选取坐标点(setq n (sslength ss ));计算坐标点数量(setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "w"));保存路径(setq i 0)(repeat n(setq spt (ssname ss i ))(setq ept (entget spt))(if (= (cdr (assoc 0 ept)) "POINT")(progn(setq lxyz (cdr (assoc 10 ept)))(setq sx (rtos (nth 1 lxyz)));将坐标值实数转换成字符(setq sy (rtos (nth 0 lxyz)))(setq sz (rtos (nth 2 lxyz)))(setq i1 (+ i 1));计算点序号(setq sn (rtos i1 2 0));将序号实数转换成字符(setq sxyz (strcat sn",," sy "," sx "," sz))(write-line sxyz ff)))(setq i (+ i 1)));repeat)(prompt "*只适合point点<< 命令:plzbsc >> *输出格式(点号,, Y,X,Z)**") (prin1)从CASS提取高程点坐标输出到文本2010-05-22 23:15:18| 分类:工程| 标签:高程点提取 cass |字号大中小订阅:2010-05-17(defun c:gcdtq()(setvar "cmdecho" 0) ;指令执行过程不响应(setq en (entsel "选择高程点:")) ;要求碰选一个高程点(setq ff (open (getfiled "文件保存为" "f:/" "txt" 1) "a"))(setq en_data (entget (car en))) ;取得元体资料列表(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt(setq py(rtos (nth 1 pt)));提取测量坐标Y值(setq px(rtos (nth 0 pt)));提取测量坐标X值(setq pz(rtos (nth 2 pt)));提取测量坐标Z值(setq sxyz (strcat px " " py " " pz))(write-line sxyz ff)(prin1))(prompt "*************** << C:gcdtq >> *****************")(prin1);修改后可以实现连续提取2011--02--25(defun c:gcdtq()(setvar "cmdecho" 0) ;指令执行过程不响应(setq ff (open (getfiled "文件保存为" "f:/" "dat" 1) "a"))(setq n 0)(while;循环语句(setq en (entsel "\n 选择高程点:")) ;要求碰选一个高程点(redraw (car en) 3);亮显高程点(setq n(+ n 1))(setq pn(rtos n 2 0))(setq en_data (entget (car en))) ;取得元体资料列表(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt(setq py(rtos (nth 1 pt)));提取测量坐标Y值(setq px(rtos (nth 0 pt)));提取测量坐标X值(setq pz(rtos (nth 2 pt)));提取测量坐标Z值(setq sxyz (strcat pn",,"px "," py "," pz))(write-line sxyz ff)(prin1)(princ sxyz)))(prompt "***** << C:gcdtq >> ***提取高程点输出为CASS格式****")(prin1);VLISP与EXCEL之间连接及数据传输和函数集2011-05-29 08:35:14| 分类:工程| 标签:|字号大中小订阅;;;*************************************************************************;;;;;; DSX-API-Excel.LSP ;;;;;; Visual LISP ActiveX API for Excel 97, 2000 and XP ;;;;;; Copyright (C)2002 David M. Stein, All rights reserved ;;;;;;*************************************************************************;;;;;; Version 2002.22 05/15/02: Initial release ;;;;;;*************************************************************************;;;;;; Code provided AS-IS without warranty of any kind given for any purpose ;;; ;;; or use, either explicitly, implicitly or as a derivative work item. ;;;;;; User assumes ANY AND ALL RISK and LIABILITY for use of any of this code ;;;;;; for any consequential damages of any kind. These functions are defined ;;; ;;; within DSX Tools 2002.22 when loaded into AutoCAD. This document is ;;;;;; provided for informational purposes only. ;;;;;;*************************************************************************;;;(vl-load-com);;;*************************************************************************;;; MODULE: DSX-TypeLib-Excel;;; DEs criptION: Returns typelib (olb) file for either Excel 97, 2000, or XP ;;; ARGS: none;;; EXAMPLE: (DSX-TypeLib-Excel);;;*************************************************************************(defun DSX-TypeLib-Excel ( / sysdrv tlb)(setq sysdrv (getenv "systemdrive"))(cond( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel8.olb")))tlb)( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel9.olb")))tlb)( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel10.olb")))tlb)( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office\\Excel.exe")))tlb)( (setq tlb (findfile (strcat sysdrv "\\Program Files\\Microsoft Office\\Office10\\Excel.exe")))tlb)));;;*************************************************************************;;; MODULE: DSX-Load-TypeLib-Excel;;; DEs criptION: Loads typelib for Excel 97, 2000 or XP (whichever is found) ;;; ARGS: none;;; EXAMPLE: (DSX-Load-TypeLib-Excel);;;*************************************************************************(defun DSX-Load-TypeLib-Excel ( / tlbfile tlbver out)(dsx-princ "\n(DSX-Load-TypeLib-Excel)")(cond( (null msxl-xl24HourClock)(if (setq tlbfile (DSX-TypeLib-Excel))(progn(setq tlbver (substr (vl-filename-base tlbfile) 6))(cond( (= tlbver "9") (princ "\nInitializing Microsoft Excel 2000...") )( (= tlbver "8") (princ "\nInitializing Microsoft Excel 97...") )( (= (vl-filename-base tlbfile) "Excel.exe")(princ "\nInitializing Microsoft Excel XP...")))(vlax-import-type-library:tlb-filename tlbfile:methods-prefix "msxl-":properties-prefix "msxl-":constants-prefix "msxl-")(if msxl-xl24HourClock (setq out T)))))( T (setq out T) ))out);;;************************************************************************* ;;; MODULE: DSX-Open-Excel-New;;; DEs criptION: Opens a new session of Excel 97, 2000 or XP ;;; ARGS: display-mode ("SHOW" or "HIDE");;; EXAMPLE: (setq xlapp (DSX-Open-Excel-New "SHOW")) ;;;************************************************************************* (defun DSX-Open-Excel-New (dmode / appsession)(dsx-princ "\n(DSX-Open-Excel-New)")(princ "\nCreating new Excel Spreadsheet file...")(cond( (setq appsession (vlax-create-object "Excel.Application")) (vlax-invoke-method(vlax-get-property appsession 'WorkBooks)'Add)(if (= (strcase dmode) "SHOW")(vla-put-visible appsession 1)(vla-put-visible appsession 0))))appsession);;;*************************************************************************;;; MODULE: DSX-Open-Excel-Exist;;; DEs criptION: Gets handle to existing (running) session of Excel 97, 2000, XP;;; ARGS: xls-filename, display-mode ("SHOW" or "HIDE");;; EXAMPLE: (setq xlapp (DSX-Open-Excel-Exist "myfile.xls" "SHOW")) ;;;*************************************************************************(defun DSX-Open-Excel-Exist (xfile dmode / appsession)(dsx-princ "\n(DSX-Open-Excel-Exist)")(princ "\nOpening Excel Spreadsheet file...")(cond( (setq fn (findfile xfile))(cond( (setq appsession (vlax-get-or-create-object "Excel.Application")) (vlax-invoke-method(vlax-get-property appsession 'WorkBooks)'Open fn)(if (= (strcase dmode) "SHOW")(vla-put-visible appsession 1)(vla-put-visible appsession 0)))))( T (alert (strcat "\nCannot locate source file: " xfile)) ))appsession);;;*************************************************************************;;; MODULE: DSX-Excel-Put-ColumnList;;; DEs criptION: Write each list member to a column (startcol) starting at row (startrow);;; ARGS: list, startrow, startcol;;; EXAMPLE: (DSX-Excel-Put-ColumnList '("A" "B" "C") 1 2) puts members into cells (1,B) (2,B) (3,B) respectively;;;*************************************************************************(defun DSX-Excel-Put-ColumnList (lst startrow startcol)(dsx-princ "\n(DSX-Excel-Put-ColumnList)")(foreach itm lst(msxl-put-value(DSX-Excel-Get-Cell range startrow startcol)itm)(setq startrow (1+ startrow))); repeat);;;*************************************************************************;;; MODULE: DSX-Excel-Put-RowList;;; DEs criptION: Write each list member to row (startrow) starting at column (startcol);;; ARGS: list, startrow, startcol;;; EXAMPLE: (DSX-Excel-Put-RowList '("A" "B" "C") 2 1) puts members into cells (1,B) (1,C) (1,D) respectively;;;*************************************************************************(defun DSX-Excel-Put-RowList (lst startrow startcol)(dsx-princ "\n(DSX-Excel-Put-RowList)")(foreach itm lst(msxl-put-value(DSX-Excel-Get-Cell range startrow startcol)itm)(setq startcol (1+ startcol))); repeat);;;*************************************************************************;;; MODULE: DSX-Excel-Put-CellColor;;; DEs criptION: Applies fill-color to specified cell;;; ARGS: row, column, color (integer);;; EXAMPLE: (DSX-Excel-Put-CellColor 1 1 14) apply color #14 to cell (1,A) ;;;*************************************************************************(defun DSX-Excel-Put-CellColor (row col intcol / rng)(setq rng (DSX-Excel-Get-Cell (msxl-get-ActiveSheet xlapp) row col)) (msxl-put-colorindex (msxl-get-interior rng) intcol));;;*************************************************************************;;; MODULE: DSX-Excel-Put-RowCellsColor;;; DEs criptION: Applies fill-color to a row of cells;;; ARGS: startrow, startcol, num-cols, color (integer);;; EXAMPLE: (DSX-Excel-Put-RowCellsColor 1 1 5 14) Start at row=1 col=1 repeat for 5 columns using color #14;;;*************************************************************************(defun DSX-Excel-Put-RowCellsColor(startrow startcol cols intcol / next)(dsx-princ "\n(DSX-Excel-Put-RowCellsColor)")(setq next startcol)(repeat cols(DSX-Excel-Put-CellColor startrow next intcol)(setq next (1+ next))));;;*************************************************************************;;; MODULE: DSX-Excel-Put-ColumnCellsColor;;; DEs criptION: Change fill color in a column of cells;;; ARGS: startrow, startcol, num-rows, color (integer);;; EXAMPLE: (DSX-Excel-Put-ColumnCellsColor 1 1 5 14) Start at row=1 col=1 repeat for 5 rows using color #14;;;*************************************************************************(defun DSX-Excel-Put-ColumnCellsColor(startrow startcol rows intcol / next)(dsx-princ "\n(DSX-Excel-Put-ColumnCellsColor)")(setq next startrow)(repeat rows(DSX-Excel-Put-CellColor next startcol intcol)(setq next (1+ next))));;;*************************************************************************;;; MODULE: DSX-Excel-Get-Cell;;; DEs criptION: Get cell object relative to range using (relrow) and (relcol) offsets;;; ARGS: range-object, relative-row, relative-col;;; EXAMPLE: (DSX-Excel-Get-Cell rng1 2 2);;;*************************************************************************(defun DSX-Excel-Get-Cell (rng relrow relcol)(dsx-princ "\n(DSX-Excel-Get-Cell)")(vlax-variant-value(msxl-get-item (msxl-get-cells rng)(vlax-make-variant relrow)(vlax-make-variant relcol))));;;*************************************************************************;;; MODULE: DSX-Excel-Get-CellValue;;; DEs criptION: Return value in given cell (row, column) of active session object (xlapp);;; ARGS: row(int), column(int);;; EXAMPLE: (DSX-Excel-Get-CellValue 1 2);;;*************************************************************************(defun DSX-Excel-Get-CellValue (row col)(dsx-princ "\n(DSX-Excel-Get-CellValue)")(vlax-variant-value(msxl-get-value(DSX-Excel-Get-Cell(msxl-get-ActiveSheet xlapp)row col))));;;*************************************************************************;;; MODULE: DSX-Excel-Get-RowValues;;; DEs criptION: Returns a list of cell values within a given row;;; ARGS: row-number(int), startcol, num-cells;;; EXAMPLE: (DSX-Excel-Get-RowValues 3 1 20) get first 20 values in row 3 ;;;*************************************************************************(defun DSX-Excel-Get-RowValues(row startcol numcells / next out)(dsx-princ "\n(DSX-Excel-Get-RowValues)")(setq next startcol)(repeat numcells(setq out (if out(append out (list (DSX-Excel-Get-CellValue row next))); row x col(list (DSX-Excel-Get-CellValue row next)); row x col)next (1+ next))); repeatout);;;*************************************************************************;;; MODULE: DSX-Excel-Get-ColumnValues;;; DEs criptION: Returns a list of cell values within a given column;;; ARGS: column-number(int), startrow, num-cells;;; EXAMPLE: (DSX-Excel-Get-ColumnValues 2 1 20) get top-20 entries in column 2 ("B");;;*************************************************************************(defun DSX-Excel-Get-ColumnValues(col startrow numcells / next out)(dsx-princ "\n(DSX-Excel-Get-ColumnValues)")(setq next startrow)(repeat numcells(setq out(if out(append out (list (DSX-Excel-Get-CellValue next col)))(list (DSX-Excel-Get-CellValue next col)))next (1+ next))); repeatout);;;*************************************************************************;;; MODULE: DSX-Excel-GetRangeValues-ByRows;;; DEs criptION: Get range values in row order and return as nested lists ;;; ARGS: startrow, startcol, num-rows, num-cols;;; EXAMPLE: (DSX-Excel-GetRangeValues-ByRows 1 1 5 10) get range values from 1A to 5J where each sublist is one row;;;*************************************************************************(defun DSX-Excel-GetRangeValues-ByRows(startrow startcol numrows numcols / nextrow rowlst outlst)(dsx-princ "\n(DSX-Excel-GetRangeValues-ByRows)")(setq nextrow startrow)(repeat numrows(setq rowlst (DSX-Excel-Get-RowValues nextrow startcol numcols)outlst (if outlst (append outlst (list rowlst)) (list rowlst))nextrow (1+ nextrow)))outlst);;;*************************************************************************;;; MODULE: DSX-Excel-GetRangeValues-ByCols;;; DEs criptION: Get range values in column order and return as nested lists ;;; ARGS: startrow, startcol, num-rows, num-cols;;; EXAMPLE: (DSX-Excel-GetRangeValues-ByCols 1 1 5 10) get range values from 1A to 5J where each sublist is one column;;;*************************************************************************(defun DSX-Excel-GetRangeValues-ByCols(startrow startcol numrows numcols / nextrow nextcol collst outlst)(dsx-princ "\n(DSX-Excel-GetRangeValues-ByCols)")(setq nextcol startcol)(repeat numcols(setq collst (DSX-Excel-Get-ColumnValues nextcol startrow numrows) outlst (if outlst (append outlst (list collst)) (list collst))nextcol (1+ nextcol)))outlst);;;*************************************************************************;;; MODULE: DSX-Excel-Get-ActiveWorkSheet;;; DEs criptION: Returns object of active worksheet in active Excel session ;;; ARGS: app (session object);;; EXAMPLE: (DSX-Excel-Get-ActiveWorkSheet xlapp);;;*************************************************************************(defun DSX-Excel-Get-ActiveWorkSheet (xlapp)(dsx-princ "\n(DSX-Excel-Get-ActiveWorkSheet)")(msxl-get-ActiveSheet xlapp));;;*************************************************************************;;; MODULE: DSX-Excel-RangeAutoFit;;; DEs criptION: Applies Auto-Fit to columns within active range;;; ARGS: active-sheet (object);;; EXAMPLE: (DSX-Excel-RangeAutoFit myxlws);;;*************************************************************************(defun DSX-Excel-RangeAutoFit (active-sheet)(dsx-princ "\n(DSX-Excel-RangeAutoFit)")(vlax-invoke-method(vlax-get-property(vlax-get-property(vlax-get-property active-sheet 'UsedRange)'Cells)'Columns)'AutoFit))(defun DSX-Excel-RangeDataFormat (active-sheet)(dsx-princ "\n(DSX-Excel-RangeDataFormat)")(vlax-put-property(vlax-get-property active-sheet "Cells")'NumberFormat "@"));;;************************************************************************* ;;; MODULE: DSX-Excel-Quit;;; DEs criptION: Quit and close Excel session (app);;; ARGS: app (session object);;; EXAMPLE: (DSX-Excel-Quit xlapp);;;************************************************************************* (defun DSX-Excel-Quit (appsession)(dsx-princ "\n(DSX-Excel-Quit)")(cond( (not (vlax-object-released-p appsession))(vlax-invoke-method appsession 'QUIT)(vlax-release-object appsession))));;;************************************************************************* ;;; MODULE: DSX-Excel-Kill;;; DEs criptION: Forces any open Excel sessions to be closed ;;; ARGS: none;;; EXAMPLE: (DSX-Excel-Kill);;;************************************************************************* (defun DSX-Excel-Kill ( / eo)(while (setq eo (vlax-get-object "Excel.Application"))(DSX-Excel-Quit eo)(vlax-release-object eo)(setq eo nil)(gc)(gc);; even this doesn't always kill the damn thing!));;;************************************************************************* ;;; MODULE:;;; DEs criptION:;;; ARGS:;;; EXAMPLE:;;;************************************************************************* ;;; Remove trailing 'nil' members from a given list(defun DSX-TrimList (lst)(cond( (/= nil (last lst)) lst)( T(DSX-TrimList (reverse (cdr (reverse lst)))))));;;************************************************************************* ;;; MODULE:;;; DEs criptION:;;; ARGS:;;; EXAMPLE:;;;************************************************************************* ;;; Convert a list of values into a list of string equivalents(defun DSX-ListStr (lst / mbr out)(setq out '())(foreach mbr lst(cond( (= mbr nil) (setq out (cons "" out)) )( (= (type mbr) 'STR)(if (member mbr '(" " " " " "))(setq out (cons "" out))(setq out (cons mbr out))))( (= (type mbr) 'INT) (setq out (cons (itoa mbr) out)) )( (= (type mbr) 'REAL)(setq out (cons (rtos mbr 2 6) out)))))(reverse out));;;************************************************************************* ;;; MODULE: DSX-Excel-Sheets;;; DEs criptION: Returns SHEETS collection from active workbook ;;; ARGS: Excel-application;;; EXAMPLE: (setq sheets (DSX-Excel-Sheets xlApp));;;*************************************************************************(defun DSX-Excel-Sheets (xlapp)(setq xlsheets (vlax-get-property xlapp "sheets")));;;*************************************************************************;;; MODULE:DSX-Excel-SheetDelete;;; DEs criptION: Delete sheet (tab) from active workbook sheets collection ;;; ARG: sheet-name, sheets-collection;;; EXAMPLE: (DSX-Excel-SheetDelete "Sheet3" xlSheets);;;*************************************************************************(defun DSX-Excel-SheetDelete (name xlsheets)(vlax-for sh xlsheets(if (= (vlax-get-property sh "Name") name)(vlax-invoke-method sh "Delete"))));;;*************************************************************************;;; MODULE: DSX-Excel-SheetAdd;;; DEs criptION: Add new sheet (tab) to sheets collection in workbook, returns sheet object;;; ARG: sheet-name, sheets-collection;;; EXAMPLE: (setq newsheet (DSX-Excel-SheetAdd "SheetX" xlSheets)) ;;;*************************************************************************(defun DSX-Excel-SheetAdd (name xlsheets)(setq newsheet (vlax-invoke-method xlsheets "Add"))(vlax-put-property newsheet "Name" name)newsheet);;;*************************************************************************;;; MODULE: DSX-Excel-WorkbookSave;;; DEs criptION: Saves active workbook to specified filename, if file exists, it is overwritten if user accepts prompt;;; ARG: workbook-object, filename;;; EXAMPLE: (DSX-Excel-WorkbookSave objWB "myfile.xls");;;*************************************************************************(defun DSX-Excel-WorkbookSave (workbook filename)(if (findfile filename)(vlax-invoke-method awb "Save")(vlax-invoke-method awb "SaveAs"filename msxl-xlNormal "" "":vlax-False :vlax-False nil)));;;*************************************************************************;;; MODULE: DSX-Excel-ActiveWorkbook;;; DEs criptION: Returns active workbook object from given Excel application session;;; ARG: Excel-application;;; EXAMPLE: (setq objWB (DSX-Excel-ActiveWorkbook xlApp));;;*************************************************************************(defun DSX-Excel-ActiveWorkbook (xlapp)(vlax-get-property xlapp "ActiveWorkbook"))(princ)完美横断面数据提取程序《CAD-lisp开发》2011-01-12 18:03:20| 分类:默认分类| 标签:横断面数据提取 cass cad lisp |字号大中小订阅(defun C:hdmsj()(setvar "cmdecho" 0)(setq ff (open (getfiled "文件保存为" "c:/" "hdm" 1) "a"))(or zx(setq zx 0))(princ "\n 是否添加中线参数:<0>添加;<1>不添加:<")(princ zx)(if (setq tmp (getreal ">: "))(setq zx tmp))(ang))(defun zxcs()(setq zzh (getreal"\n请输入中桩高程:"))(setq zxh (strcat "next"))(write-line zxh ff)(setq zzh0 (rtos zzh 2 3))(setq zzh1 (strcat "0,"zzh0))(write-line zzh1 ff)(setq zzh00 (rtos (- zzh 3) 2 3))(setq zzh2 (strcat "0," zzh00))(write-line zzh2 ff))(defun ang()(setq pt1 (getpoint "\n拾取纵断面上的一点:"))(setq x1 (car pt1))(setq y1 (cadr pt1))(setq pt2 (getpoint "\n拾取纵断面上的第二点(道路前进方向):"))(setq x2 (car pt2))(setq y2 (cadr pt2))(setq pt11 (list y1 x1))(setq pt12 (list y2 x2))(setq ang (angle pt11 pt12))(hdm));拾取高程点进行平距计算(defun hdm()(setvar "cmdecho" 0) ;指令执行过程不响应(setq zh (getreal"\n请输入桩号:"))(setq zh1 (rtos zh 2 3))(setq zh2 (strcat "BEGIN," zh1))(write-line zh2 ff)(while (setq en (entsel "\n选择高程点:"))(setvar "cmdecho" 0)(redraw (car en) 3)(setq en_data (entget (car en))) ;取得元体资料列表(setq pt (cdr (assoc 10 en_data))) ;求得高程点坐标pt(setq py (nth 0 pt));提取测量坐标系Y值(setq px (nth 1 pt));提取测量坐标洗X值(setq cj (-(* (- py x1) (cos ang)) (* (- px y1) (sin ang))));该行要注意数学坐标与测量坐标的互换计算垂直距离(cj)(setq dist (rtos cj 2 3))(setq pz(rtos (nth 2 pt)2 3));提取测量坐标系Z值(setq pdz (strcat dist","pz));输出为CASS数据格式(平距,高程)(write-line pdz ff);将数据写入文本(princ pdz))(while (/= 52 (getvar "cmdactive");(if (= zx 0)(zxcs));判断是否写入中线参数(setq xuanze (getreal"\n 1.选取下一个横断面高程点;2.选择新的切线;3.退出<1>:"))(if (= xuanze nil)(hdm))(if (= xuanze 1 )(hdm))(if (= xuanze 2 ) (fwjjs))(if (= xuanze 3 )(close ff)。