乐筑天下

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

[编程交流] LISP: export linetype from dra

[复制链接]

15

主题

83

帖子

68

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
75
发表于 2022-7-6 14:28:04 | 显示全部楼层 |阅读模式
  1. ;;;   ----------- LTExtract - Version 1.1 -----------;;;   Copyright (C) 2002-2008  by ResourceCAD International;;;   Author:   K.E. Blackie;;;   ;;;   ;;;   BCI COMPUTER SOLUTIONS PROVIDES THIS PROGRAM "AS IS" AND WITH;;;   ALL FAULTS. RESOURCECAD INTERNATIONAL SPECIFICALLY DISCLAIMS ANY;;;   IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR;;;   USE.  RESOURCECAD INTERNATIONAL DOES NOT WARRANT THAT THE OPERATION;;;   OF THE PROGRAM WILL BE UNINTERRUPTED OR ERROR FREE.;;;   ;;;   ;;;   ResouceCAD International;;;   http://www.resourcecad.com;;;   ;;;   DESCRIPTION;;;   LTExtract will extract all of the linetypes defined in a drawing to a seperate;;;   linetype definition file, including complex linetypes using text and shape;;;   modifiers.;;;;;;   August 17, 2002;;;   April 23, 2008;;;;;;   ------------------------------------------------------------(defun c:ltextract () (setq ltlist (tblnext "LTYPE" t)) (if ltlist   (setq ltlist (entget (tblobjname "LTYPE" (cdr (assoc 2 ltlist))))) ) (setq ltfile (getvar "dwgname")) (if (= (strcase (substr ltfile (- (strlen ltfile) 3) 4))    (strcase ".dwg")     )   (setq     ltfile (strcat (substr ltfile 1 (- (strlen ltfile) 4)) ".lin")   )   (setq ltfile (strcat ltfile ".lin")) ) (setq ltfile (getfiled "Save Linetype Definition As" ltfile "lin" 9)) (if ltfile   (progn     (setq fn (open ltfile "w"))     (while ltlist   (setq ltname (strcat "*" (strcase (cdr (assoc 2 ltlist))))         ltdesc (cdr (assoc 3 ltlist))   )   (setq ltdef "A"         wval nil   )   (setq ltlist (member (assoc 49 ltlist) ltlist))   (while (assoc 49 ltlist)     (setq wval (get74 ltlist))     (setq def (cdr (assoc 49 ltlist)))     (setq def (strcat "," (rtos def 2 ))     (if wval       (setq ltdef (strcat ltdef wval def))       (setq ltdef (strcat ltdef def))     )     (if (> (length ltlist) 1)       (setq ltlist (cdr (member (assoc 49 ltlist) ltlist)))       (setq ltlist (list nil))     )   )   (setq ltlist (tblnext "LTYPE"))   (if ltlist     (progn       (setq ltlist          (entget (tblobjname "LTYPE" (cdr (assoc 2 ltlist)))          )       )     )   )   (if (/= ltdef "A")     (progn       (write-line (strcat ltname "," ltdesc) fn)       (write-line ltdef fn)     )   )     )     (close fn)   ) ) (princ))(defun get74 (wlist / rval) (setq ass74 (cdr (assoc 74 wlist))) (cond   ((= ass74 0) (return nil nil nil nil))   ((= ass74 1)    (return (cdr (assoc 2 (entget (cdr (assoc 340 wlist)))))        nil        "a"        nil    )   )   ((= ass74 2)    (return (cdr (assoc 2 (entget (cdr (assoc 340 wlist)))))        (cdr (assoc 9 wlist))        "r"        nil    )   )   ((= ass74 3)    (return (cdr (assoc 2 (entget (cdr (assoc 340 wlist)))))        (cdr (assoc 9 wlist))        "a"        nil    )   )   ((= ass74 4)    (return (cdr (assoc 3 (entget (cdr (assoc 340 wlist)))))        nil        "r"        (cdr (assoc 75 wlist))    )   )   ((= ass74 5)    (return (cdr (assoc 3 (entget (cdr (assoc 340 wlist)))))        nil        "a"        (cdr (assoc 75 wlist))    )   )   (T (return nil nil nil nil)) ) rval)(defun return (shx text rot shp / ttext) (setq test (cdr (assoc 50 wlist))) (if (and test rot)   (setq rot (strcat rot "=" (angtos test))) ) (setq test (cdr (assoc 46 wlist))) (if (and test rot)   (setq rot (strcat rot ",S=" (rtos test 2 )) ) (setq test (cdr (assoc 44 wlist))) (if (and test rot)   (setq rot (strcat rot ",X=" (rtos test 2 )) ) (setq test (cdr (assoc 45 wlist))) (if (and test rot)   (setq rot (strcat rot ",Y=" (rtos test 2 )) ) (if text   (setq ttext (strcat ",["" text ""," shx "," rot "]")) ) (if (and (not text) shp)   (setq ttext (strcat ",[" (getname shp shx) "," shx "," rot "]")) ) (setq rval ttext))(defun getname (shape shapefile) (setq shapefile (findfile shapefile)) (if (setq sfn (open shapefile "r"))   (progn     (repeat 23   (read-char sfn)     )     (setq lownum (read-char sfn))     (read-char sfn)     (setq charcount (- shape lownum))     (setq hignum (read-char sfn))     (read-char sfn)     (setq shpcount (read-char sfn))     (read-char sfn)     (repeat (* shpcount 4)   (read-char sfn)     )     (setq zerocount 0)     (while (< zerocount (* charcount 2))   (setq this (read-char sfn))   (if (= this 0)     (setq zerocount (1+ zerocount))   )     )     (setq char1 (read-char sfn))     (setq name "")     (while (/= 0 char1)   (setq name (strcat name (chr char1)))   (setq char1 (read-char sfn))     )     (close sfn)     name   ) ))(princ)
Here is a lisp that found on internet, but not works (for me), can anyone try to see what happened here?? THX...
This lisp could be very usable for everyone..
Here is page where I picked it up..
http://www.theswamp.org/index.php?topic=506.msg6241
回复

使用道具 举报

VVA

1

主题

308

帖子

308

银币

初来乍到

Rank: 1

铜币
8
发表于 2022-7-6 15:16:29 | 显示全部楼层
Try to use the a bit changed code. See post #8.
Changes:
回复

使用道具 举报

15

主题

209

帖子

121

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
163
发表于 2022-7-6 15:54:05 | 显示全部楼层
You could also post this to theswamp, I am sure that Keith would be more than happy to help you.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 00:15 , Processed in 0.473694 second(s), 58 queries .

© 2020-2025 乐筑天下

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