明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 67989|回复: 268

【Gu_xl】[原创]实用工具:Block 自动转为Lisp源代码

  [复制链接]
发表于 2010-7-18 19:39:00 | 显示全部楼层 |阅读模式
本帖最后由 Gu_xl 于 2016-2-25 14:14 编辑


我们在编写AutoCAD应用程序时,经常会使用到符号库,在程序分发时必须将符号库随程序一起分发,一般符号库的图形很多,拷贝分发不是很方便,而且符号库都暴露在任何人面前。为了避免这种情况,将符号在程序中用代码生成是一种很好的办法,但是这么多符号,一句一句用代码来写,好像不太现实!
好了,我这提供一个程序,能够自动将符号转成源代码,成百上千个符号,转瞬间即可全部转为lisp源代码,实现符号库的封装!
请下载附件,将“图块代码生成器.VLX”添加到AutoCAD启动组里,每次AutoCAD启动时程序可自动加载!调用命令:BlockToLisp.
使用方法:
1、假设符号库文件存放在“c:\符号库\”目录下,打开CAD,新建图形,将符号库内DWG文件以块全部插入该图形,使用下列程序可一次性将DWG文件插入图形图形:
代码:

  
(defun c:BlockIn (/ f)
  (setierr)
  (foreach f (vl-sort (gxl-file-Dos_dir "c:\\符号库\\*.dwg") '<)
    (command "-insert" (strcat "c:\\符号库\\" f) '(0 0 0) 1 1  0)
    )
  (reerr)
  )
  

2、图形插入后,在命令行键入:BlockToLisp,自动生成图块文件MakeBlock.Lsp。
3.、在生成的代码中定义如下函数,
代码:

  
;;;检查图块是否建立,如未建立图块则自动创建图块,参数:B_Name  块名
(defun gxl-Blk-Check (B_Name / curlay B_Name1)
  (setq B_Name1 (gxl-Str-Subst "]" ")" (gxl-Str-Subst "[" "(" B_Name)))
  (setq curlay (getvar "Clayer"))
  (if (not (member B_Name (GXL-TABLE "block")))
    (progn
      (if (or (= 'USUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))
	      (= 'SUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))
	      )
	(eval (read (strcat "(MakeBlock-" B_Name1 ")"))))
      )
    )
  (setvar "clayer" curlay)
  B_Name
  )
  

每次插入符号前调用该函数,即可实现图块的插入
,如符号库中有符号名为:路灯.dwg文件,则程序自动生成的函数名为:MakeBlock-路灯 ,块名为:“l路灯”,插入路灯前调用如下函数,即可实现图块“路灯”的创建:
代码:

  
(gxl-Blk-Check  "路灯")
  

说明:符号图形中实体可包括如下实体:Line/Arc/Circle/Lwpolyline/polyline/spline/Attdef/Block/solid/Hatch/Text/Mtext/Ellipse/Point,除此之外实体不能支持。Block支持嵌套!
附件见5楼!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x

本帖被以下淘专辑推荐:

 楼主| 发表于 2010-9-29 12:11:00 | 显示全部楼层
本帖最后由 Gu_xl 于 2012-3-16 20:00 编辑

应大家的要求,现将源码公布如下,供大家共同交流:

  1. ;;; gxl-Blk-Check 检查定义图块
  2. ;;;C:Block->Lisp1 由图块自动转为Lisp代码,可以处理嵌套块,但不能处理复杂的块
  3. ;;; c:BlockIn 在图形中插入某目录下的全部图形,
  4. ;;;******************************************************
  5. ;;;C:Block->Lisp1 由图块自动转为Lisp代码,可以处理嵌套块,但不能处理复杂的块
  6. (DEFUN C:BlockToLisp (/ ListMutiBlock       MakeEntity BlockLisp
  7.    BlockLisp1 blkList    OpenFile  en
  8.    ss    ss1       pt1  pt2
  9.    R    Ang1       Ang2  mk
  10.    mn    tmp_Fn     BlockName  BlockNameList
  11.          ) ;_ /
  12.   ;;;展开嵌套块中最基本图块单元,由低到高顺序
  13. (defun ListMutiBlock (BlockName / rtn listblkref blklst obj obj1 Bname)
  14.   (defun listblkref (Name / objblk rtn1 obj2)
  15.     (setq objblk (vla-item (vla-get-blocks *ACDOCUMENT*) Name)
  16.    rtn1 (list Name))
  17.   (vlax-for obj2 (vla-Item (vla-get-Blocks *AcDocument*) (vla-get-name objblk))
  18.    (if (= "AcDbBlockReference" (vla-get-ObjectName obj2))
  19.      (progn
  20.        (setq Name (vla-get-Name obj2))
  21.      ;(if (listblkref name) (setq rtn1 (append rtn1 (list (list name (listblkref name)))))(setq rtn1 (append (list name))))
  22.      (setq rtn1 (append rtn1 (list  (listblkref name))))
  23.      )
  24.      )
  25.     (setq obj2 nil)
  26.    )
  27.     (setq objblk nil)
  28.     (gxl-ListDumpAtom rtn1)
  29.   )
  30.   (setq obj (vla-item (vla-get-blocks *ACDOCUMENT*) BlockName))
  31.   (vlax-for obj1 obj
  32.      (if (= "AcDbBlockReference" (vla-get-ObjectName obj1))
  33.        (progn
  34.   (setq  Bname (vla-get-Name obj1))
  35.   ;(if (listblkref Bname) (setq rtn (append rtn (list (list Bname (listblkref Bname))))) (setq rtn (append (list Bname))))
  36.      (setq rtn (append rtn  (list  (listblkref Bname))))
  37.      )
  38.    )
  39.     (setq obj1 nil)
  40.    )
  41.   (setq obj nil)
  42. (setq rtn (gxl-RemoveItem nil (gxl-ListDumpAtom rtn)))
  43.   (reverse (setq rtn (gxl-onelist rtn)))
  44. )
  45.   ;;;块写实体,包含Hatch实体
  46.   (defun MakeEntity (obj /        pt1      pt2
  47.     La        Plottable     color
  48.     LaColor       lineType      LineTypeScale
  49.     R        pts      clo
  50.     CONSTANTWIDTH StartTangent  EndTangent
  51.     Height        xz      kb
  52.     qx        Alignment     style
  53.     objTextStyle  FontFile      BigFontFile
  54.     Font        styleHeight   stylebliqueAngle
  55.     styleScale    TextString    textaligmentpoint
  56.     Width        AttachmentPoint
  57.     InsertionPoint       mode
  58.     $Prompt       Tag      Value
  59.     P1        P2      P3
  60.     P4        Center      MajorAxis
  61.     RadiusRatio   StartAngle    EndAngle
  62.     PatternType   PatternName   Associative
  63.     NumberOfLoops PatternScale  PatternAngle
  64.     HatchStyle    HatchObjectType
  65.     InsPt        BName      Xscale
  66.     Yscale        Zscale      Rotation
  67.            lineweight
  68.    ) ;_ obj
  69.     (setq ObjectName (vla-get-ObjectName obj)
  70.    Handle (vla-get-Handle obj)
  71.    )
  72.     (cond ((= "AcDbLine" ObjectName)
  73.     (setq pt1 (GXL-STR-STOA (vlax-curve-getStartPoint obj))
  74.    pt2 (GXL-STR-STOA (vlax-curve-getEndPoint obj))
  75.    La (vla-get-Layer obj)
  76.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  77.    color (vla-get-color obj)
  78.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  79.    lineType (vla-get-linetype obj)
  80.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  81.    lineweight (rtos (vla-get-lineweight obj) 2)
  82.    )
  83.     (WRITE-LINE (strcat "   (setq obj1 (GXL-AX:ADDLINE obj \'" pt1 " \'" pt2 "))") OpenFile)
  84.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  85.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  86.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  87.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  88.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  89.     (WRITE-LINE (strcat
  90.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  91.     (WRITE-LINE (strcat
  92.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  93.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  94.     (WRITE-LINE (strcat
  95.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  96.     (WRITE-LINE (strcat "    (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  97.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  98.     )
  99.    ((= "AcDbCircle" ObjectName)
  100.     (setq pt1 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-center obj)))
  101.    R (rtos (vla-get-radius obj) 2)
  102.    La (vla-get-Layer obj)
  103.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  104.    color (vla-get-color obj)
  105.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  106.    lineType (vla-get-linetype obj)
  107.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  108.    lineweight (rtos (vla-get-lineweight obj) 2)
  109.    )
  110.     (WRITE-LINE (strcat "   (setq obj1 (GXL-AX:ADDCIRCLE obj \'" pt1 " " R "))") OpenFile)
  111.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  112.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  113.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  114.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  115.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  116.     (WRITE-LINE (strcat
  117.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  118.     (WRITE-LINE (strcat
  119.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  120.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  121.     (WRITE-LINE (strcat
  122.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  123.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  124.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  125.     )
  126.    ((= "AcDbArc" ObjectName)
  127.     (setq pt1 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-center obj)))
  128.    R (rtos (vla-get-radius obj) 2)
  129.    Ang1 (rtos (vla-get-StartAngle obj) 2)
  130.    Ang2 (rtos (vla-get-endAngle obj) 2)
  131.    La (vla-get-Layer obj)
  132.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  133.    color (vla-get-color obj)
  134.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  135.    lineType (vla-get-linetype obj)
  136.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  137.    lineweight (rtos (vla-get-lineweight obj) 2)
  138.    )
  139.     (WRITE-LINE (strcat "   (setq obj1 (gxl-AX:AddArc obj \'" pt1 " "  R " "  Ang1 " "  Ang2 "))") OpenFile)
  140.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  141.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  142.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  143.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  144.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  145.     (WRITE-LINE (strcat
  146.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  147.     (WRITE-LINE (strcat
  148.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  149.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  150.     (WRITE-LINE (strcat
  151.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  152.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  153.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  154.     )
  155.    ((= "AcDbPolyline" ObjectName)
  156.     (setq pts (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-Coordinates obj)))
  157.    bulges (cadr (GXL-GET_POLY_DATA obj))
  158.    clo (vla-get-Closed obj)
  159.    CONSTANTWIDTH (vla-get-ConstantWidth obj)
  160.    La (vla-get-Layer obj)
  161.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  162.    color (vla-get-color obj)
  163.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  164.    lineType (vla-get-linetype obj)
  165.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  166.    lineweight (rtos (vla-get-lineweight obj) 2)
  167.    )
  168.     (WRITE-LINE
  169.       (strcat
  170.         "   (setq obj1 (vla-AddLightWeightPolyline obj (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 1 "
  171.         (itoa (length (read pts)))
  172.         "))\'"
  173.         pts
  174.         "))))"
  175.       ) ;_ strcat
  176.       OpenFile
  177.     ) ;_ WRITE-LINE
  178.     (setq n 0)
  179.     (foreach bulge bulges
  180.       (if (/= bulge 0.0) (WRITE-LINE (strcat "  (vla-SetBulge obj1 " (itoa n) " " (rtos bulge 2) ")") OpenFile))
  181.       (setq n (1+ n))
  182.       )
  183.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  184.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  185.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  186.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  187.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  188.     (if (= clo :vlax-true)
  189.       (WRITE-LINE  "   (vla-put-Closed obj1 :vlax-true)" OpenFile)
  190.       )
  191.     (if (not (equal CONSTANTWIDTH 0.0))
  192.       (progn
  193.         (setq CONSTANTWIDTH (rtos CONSTANTWIDTH 2))
  194.         (WRITE-LINE  (strcat "   (vla-put-ConstantWidth obj1 " CONSTANTWIDTH ")") OpenFile)
  195.         )
  196.       )
  197.     (WRITE-LINE (strcat
  198.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  199.     (WRITE-LINE (strcat
  200.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  201.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  202.     (WRITE-LINE (strcat
  203.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  204.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  205.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  206.     )
  207.    ((= "AcDb2dPolyline" ObjectName)
  208.     (setq pts (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-Coordinates obj)))
  209.    bulges (cadr (GXL-GET_POLY_DATA obj))
  210.    clo (vla-get-Closed obj)
  211.    CONSTANTWIDTH (vla-get-ConstantWidth obj)
  212.    La (vla-get-Layer obj)
  213.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  214.    color (vla-get-color obj)
  215.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  216.    lineType (vla-get-linetype obj)
  217.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  218.    lineweight (rtos (vla-get-lineweight obj) 2)
  219.    )
  220.     (WRITE-LINE
  221.       (strcat
  222.         "   (setq obj1 (vla-AddPolyline obj (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 1 "
  223.         (itoa (length (read pts)))
  224.         "))\'"
  225.         pts
  226.         "))))"
  227.       ) ;_ strcat
  228.       OpenFile
  229.     ) ;_ WRITE-LINE
  230.     (setq n 0)
  231.     (foreach bulge bulges
  232.       (if (/= bulge 0.0) (WRITE-LINE (strcat "  (vla-SetBulge obj1 " (itoa n) " " (rtos bulge 2) ")") OpenFile))
  233.       (setq n (1+ n))
  234.       )
  235.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  236.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  237.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  238.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  239.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  240.     (if (= clo :vlax-true)
  241.       (WRITE-LINE  "   (vla-put-Closed obj1 :vlax-true)" OpenFile)
  242.       )
  243.     (if (not (equal CONSTANTWIDTH 0.0))
  244.       (progn
  245.         (setq CONSTANTWIDTH (rtos CONSTANTWIDTH 2))
  246.         (WRITE-LINE  (strcat "   (vla-put-ConstantWidth obj1 " CONSTANTWIDTH ")") OpenFile)
  247.         )
  248.       )
  249.     (WRITE-LINE (strcat
  250.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  251.     (WRITE-LINE (strcat
  252.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  253.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  254.     (WRITE-LINE (strcat
  255.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  256.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  257.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  258.     )
  259.    ((= "AcDbSpline" ObjectName)
  260.     (setq pts (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-FitPoints obj)))
  261.    clo (vla-get-Closed obj)
  262.    La (vla-get-Layer obj)
  263.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  264.    StartTangent (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-StartTangent obj)))
  265.    EndTangent (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-endTangent obj)))
  266.    color (vla-get-color obj)
  267.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  268.    lineType (vla-get-linetype obj)
  269.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  270.    lineweight (rtos (vla-get-lineweight obj) 2)
  271.    )
  272.     (WRITE-LINE
  273.       (strcat
  274.         "   (setq obj1 (vla-AddSpline obj (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 1 "
  275.         (itoa (length (read pts)))
  276.         "))\'"
  277.         pts
  278.         ")) (vlax-3d-point \'" StartTangent ") (vlax-3d-point \'" EndTangent ")))"
  279.       ) ;_ strcat
  280.       OpenFile
  281.     ) ;_ WRITE-LINE
  282.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  283.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  284.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  285.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  286.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  287.     (if (= clo :vlax-true)
  288.       (WRITE-LINE  "   (vla-put-Closed obj1 :vlax-true)" OpenFile)
  289.       )
  290.    
  291.     (WRITE-LINE (strcat
  292.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  293.     (WRITE-LINE (strcat
  294.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  295.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  296.     (WRITE-LINE (strcat
  297.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  298.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  299.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  300.     )
  301.    ((= "AcDbText" ObjectName)
  302.     (setq pt1 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-InsertionPoint obj)))
  303.    Height (rtos (vla-get-Height obj) 2)
  304.    xz (rtos (vla-get-Rotation obj) 2)
  305.    kb (rtos (vla-get-ScaleFactor obj) 2)
  306.    qx (rtos (vla-get-ObliqueAngle obj) 2)
  307.    Alignment (vla-get-alignment obj)
  308.    style (vla-get-StyleName obj)
  309.    objTextStyle (vla-Item (vla-get-textstyles *AcDocument*) style)
  310.    FontFile (vla-get-FontFile objTextStyle)
  311.    BigFontFile (vla-get-BigFontFile objTextStyle)
  312.    Font (strcat FontFile "," BigFontFile)
  313.    styleHeight (rtos (vla-get-Height objTextStyle) 2)
  314.    stylebliqueAngle (rtos (vla-get-ObliqueAngle objTextStyle)2)
  315.    ;styleScale (rtos (vla-get-ScaleFactor objTextStyle) 2)
  316.    TextString (vla-get-TextString obj)
  317.    La (vla-get-Layer obj)
  318.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  319.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  320.    color (vla-get-color obj)
  321.    textaligmentpoint (GXL-STR-STOA (GXL-NUM-AX->LISPVALUE(vla-get-TextAlignmentPoint obj)))
  322.    lineweight (rtos (vla-get-lineweight obj) 2)
  323.    )
  324.     (cond ((= 0 Alignment) (setq Alignment "acAlignmentLeft"))
  325.    ((= 1 Alignment) (setq Alignment "acAlignmentCenter"))
  326.    ((= 2 Alignment) (setq Alignment "acAlignmentRight"))
  327.    ((= 3 Alignment) (setq Alignment "acAlignmentAligned"))
  328.    ((= 4 Alignment) (setq Alignment "acAlignmentMiddle"))
  329.    ((= 5 Alignment) (setq Alignment "acAlignmentFit"))
  330.    ((= 6 Alignment) (setq Alignment "acAlignmentTopLeft"))
  331.    ((= 7 Alignment) (setq Alignment "acAlignmentTopCenter"))
  332.    ((= 8 Alignment) (setq Alignment "acAlignmentTopRight"))
  333.    ((= 9 Alignment) (setq Alignment "acAlignmentMiddleLeft"))
  334.    ((= 10 Alignment) (setq Alignment "acAlignmentMiddleCenter"))
  335.    ((= 11 Alignment) (setq Alignment "acAlignmentMiddleRight"))
  336.    ((= 12 Alignment) (setq Alignment "acAlignmentBottomLeft"))
  337.    ((= 13 Alignment) (setq Alignment "acAlignmentBottomCenter"))
  338.    ((= 14 Alignment) (setq Alignment "acAlignmentBottomRight"))
  339.    (t (setq Alignment (rtos Alignment 2)))
  340.    )
  341.     (WRITE-LINE (strcat "   (gxl-AX:MakeStyle "" style "" 0.0 1 0 "" FontFile "" "" BigFontFile "")") OpenFile)
  342.     (WRITE-LINE (strcat "   (setq obj1 (gxl-AX:AddText obj "" TextString "" \'" pt1 " " Height " " xz " " kb " " qx " " Alignment " "" style ""))") OpenFile)
  343.     (if (/= Alignment "acAlignmentLeft") (WRITE-LINE (strcat "   (vla-put-TextAlignmentPoint obj1 (vlax-3d-point \'" textaligmentpoint "))") OpenFile))
  344.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  345.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  346.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  347.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  348.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  349.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  350.     )
  351.    ((= "AcDbMText" ObjectName)
  352.     (setq pt1 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-InsertionPoint obj)))
  353.    Height (rtos (vla-get-Height obj) 2)
  354.    xz (rtos (vla-get-Rotation obj) 2)
  355.    Width (rtos (vla-get-width obj) 2)
  356.    style (vla-get-StyleName obj)
  357.    objTextStyle (vla-Item (vla-get-textstyles *AcDocument*) style)
  358.    FontFile (vla-get-FontFile objTextStyle)
  359.    BigFontFile (vla-get-BigFontFile objTextStyle)
  360.    Font (strcat FontFile "," BigFontFile)
  361.    styleHeight (rtos (vla-get-Height objTextStyle) 2)
  362.    stylebliqueAngle (rtos (vla-get-ObliqueAngle objTextStyle)2)
  363.    TextString (vla-get-TextString obj)
  364.    La (vla-get-Layer obj)
  365.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  366.    color (vla-get-color obj)
  367.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  368.    AttachmentPoint (vla-get-AttachmentPoint obj)
  369.    lineweight (rtos (vla-get-lineweight obj) 2)
  370.    )
  371.     (cond ((= 1 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointTopLeft"))
  372.    ((= 2 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointTopCenter"))
  373.    ((= 3 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointTopRight"))
  374.    ((= 4 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointMiddleLeft"))
  375.    ((= 5 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointMiddleCenter"))
  376.    ((= 6 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointMiddleRight"))
  377.    ((= 7 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointBottomLeft"))
  378.    ((= 8 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointBottomCenter"))
  379.    ((= 9 AttachmentPoint) (setq AttachmentPoint "acAttachmentPointBottomRight"))
  380.    )
  381.     (WRITE-LINE (strcat "   (gxl-AX:MakeStyle "" style "" 0.0 1 0  "" FontFile "" "" BigFontFile "")") OpenFile)
  382.     (WRITE-LINE (strcat "   (setq obj1 (gxl-AX:AddMText obj "  "\'" pt1 " " Width " "" (substr (gxl-strunparse (GXL-STRPARSE TextString "\") "\\\") 2) "" " Height " " xz   " "" style ""))") OpenFile)
  383.     (WRITE-LINE (strcat "   (vla-put-AttachmentPoint obj1 " AttachmentPoint ")") OpenFile)
  384.     (WRITE-LINE (strcat "   (vla-put-InsertionPoint obj1 (vlax-3d-point \'" pt1 "))") OpenFile)
  385.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  386.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  387.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  388.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  389.     )
  390.    ((= "AcDbAttributeDefinition" ObjectName)
  391.     (setq InsertionPoint (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-InsertionPoint obj)))
  392.    Height (rtos (vla-get-Height obj) 2)
  393.    mode (vla-get-mode obj)
  394.    $Prompt (vla-get-promptString obj)
  395.    Tag (vla-get-TagString obj)
  396.    Value (vla-get-TextString obj)
  397.    Alignment (vla-get-alignment obj)
  398.    style (vla-get-StyleName obj)
  399.    objTextStyle (vla-Item (vla-get-textstyles *AcDocument*) style)
  400.    FontFile (vla-get-FontFile objTextStyle)
  401.    BigFontFile (vla-get-BigFontFile objTextStyle)
  402.    Font (strcat FontFile "," BigFontFile)
  403.    styleHeight (rtos (vla-get-Height objTextStyle) 2)
  404.    stylebliqueAngle (rtos (vla-get-ObliqueAngle objTextStyle)2)
  405.    kb (rtos (vla-get-ScaleFactor obj) 2)
  406.    La (vla-get-Layer obj)
  407.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  408.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  409.    color (vla-get-color obj)
  410.    textaligmentpoint (GXL-STR-STOA (GXL-NUM-AX->LISPVALUE(vla-get-TextAlignmentPoint obj)))
  411.    )
  412.     (cond ((= 0 Alignment) (setq Alignment "acAlignmentLeft"))
  413.    ((= 1 Alignment) (setq Alignment "acAlignmentCenter"))
  414.    ((= 2 Alignment) (setq Alignment "acAlignmentRight"))
  415.    ((= 3 Alignment) (setq Alignment "acAlignmentAligned"))
  416.    ((= 4 Alignment) (setq Alignment "acAlignmentMiddle"))
  417.    ((= 5 Alignment) (setq Alignment "acAlignmentFit"))
  418.    ((= 6 Alignment) (setq Alignment "acAlignmentTopLeft"))
  419.    ((= 7 Alignment) (setq Alignment "acAlignmentTopCenter"))
  420.    ((= 8 Alignment) (setq Alignment "acAlignmentTopRight"))
  421.    ((= 9 Alignment) (setq Alignment "acAlignmentMiddleLeft"))
  422.    ((= 10 Alignment) (setq Alignment "acAlignmentMiddleCenter"))
  423.    ((= 11 Alignment) (setq Alignment "acAlignmentMiddleRight"))
  424.    ((= 12 Alignment) (setq Alignment "acAlignmentBottomLeft"))
  425.    ((= 13 Alignment) (setq Alignment "acAlignmentBottomCenter"))
  426.    ((= 14 Alignment) (setq Alignment "acAlignmentBottomRight"))
  427.    (t (setq Alignment (rtos Alignment 2)))
  428.    )
  429.     (cond ((= 0 mode) (setq mode "acAttributeModeNormal"))
  430.    ((= 1 mode) (setq mode "acAttributeModeInvisible"))
  431.    ((= 2 mode) (setq mode "acAttributeModeConstant"))
  432.    ((= 3 mode) (setq mode "acAttributeModeVerify"))
  433.    ((= 4 mode) (setq mode "acAttributeModePreset"))
  434.    (t (setq mode (rtos mode 2)))
  435.    )
  436.     (WRITE-LINE (strcat "   (gxl-MakeStyle "" style "" 0.0 1 0 1 "" FontFile "" "" BigFontFile "")") OpenFile)
  437.     (WRITE-LINE (strcat "   (setq obj1 (GXL-AX:ADDATT obj " Height " "  Mode " ""  $Prompt "" \'"  InsertionPoint " ""  Tag  "" """ "))") OpenFile)
  438.     (WRITE-LINE (strcat "   (vla-put-ScaleFactor obj1 " kb ")") OpenFile)
  439.            (WRITE-LINE (strcat "   (vla-put-alignment obj1 " Alignment ")") OpenFile)
  440.            ;(WRITE-LINE (strcat "  (vla-put-TextAlignmentPoint obj1 (vlax-3d-point \'" InsertionPoint "))") OpenFile)
  441.     (if (/= Alignment "acAlignmentLeft") (WRITE-LINE (strcat "   (vla-put-TextAlignmentPoint obj1 (vlax-3d-point \'" textaligmentpoint "))") OpenFile))
  442.            (WRITE-LINE (strcat "   (vla-put-StyleName obj1 "" style "")") OpenFile)
  443.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  444.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La "") " Plottable ")") OpenFile))
  445.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  446.     (if (/= "0" La) (WRITE-LINE (strcat "   (vla-put-Layer obj1 "" La "")") OpenFile))
  447.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  448.     )
  449.    ((= "AcDbPoint" ObjectName)
  450.     (setq InsertionPoint (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-coordinates obj)))
  451.    La (vla-get-Layer obj)
  452.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  453.    color (vla-get-color obj)
  454.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  455.    )
  456.     (WRITE-LINE (strcat "   (setq obj1 (gxl-AX:AddPoint obj \'" InsertionPoint "))") OpenFile)
  457.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  458.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  459.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  460.     (if (/= "0" La) (WRITE-LINE (strcat "   (vla-put-Layer obj1 "" La "")") OpenFile))
  461.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  462.    
  463.     )
  464.    ((= "AcDbSolid" ObjectName)
  465.     (setq P1 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-coordinate obj 0)))
  466.    P2 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-coordinate obj 1)))
  467.    P3 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-coordinate obj 2)))
  468.    P4 (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-coordinate obj 3)))
  469.    La (vla-get-Layer obj)
  470.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  471.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  472.    color (vla-get-color obj)
  473.    )
  474.     (WRITE-LINE (strcat "(setq obj1 (gxl-AX:AddSolid obj \'" p1 " \'" p2 " \'" p3 " \'" p4 "))") OpenFile)
  475.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  476.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  477.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  478.     (if (/= "0" La) (WRITE-LINE (strcat "   (vla-put-Layer obj1 "" La "")") OpenFile))
  479.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)   
  480.     )
  481.    ((= "AcDbEllipse" ObjectName)
  482.     (setq Center (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-center obj)))
  483.    MajorAxis (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-MajorAxis obj)))
  484.    RadiusRatio (rtos (vla-get-RadiusRatio obj) 2)
  485.    StartAngle (rtos (vla-get-StartAngle obj) 2)
  486.    EndAngle (rtos (vla-get-endAngle obj) 2)
  487.    La (vla-get-Layer obj)
  488.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  489.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  490.    color (vla-get-color obj)
  491.    lineType (vla-get-linetype obj)
  492.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  493.    lineweight (rtos (vla-get-lineweight obj) 2)
  494.    )
  495.     (WRITE-LINE (strcat "   (setq obj1 (GXL-AX:ADDELLIPSE obj \'" Center " \'"  MajorAxis " " RadiusRatio  "))") OpenFile)
  496.     (WRITE-LINE (strcat "   (vla-put-StartAngle obj1 " StartAngle ")") OpenFile)
  497.     (WRITE-LINE (strcat "   (vla-put-endAngle obj1 " EndAngle ")") OpenFile)
  498.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  499.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  500.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  501.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  502.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  503.     (WRITE-LINE (strcat
  504.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  505.     (WRITE-LINE (strcat
  506.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  507.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  508.     (WRITE-LINE (strcat
  509.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  510.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  511.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-lineweight obj1 "" lineweight "")") OpenFile))
  512.     )
  513.            ((= "AcDbHatch" ObjectName)
  514.     (setq PatternType (vla-get-PatternType obj)
  515.    PatternName  (vla-get-PatternName obj)
  516.    Associative (GXL-STR-STOA (vla-get-AssociativeHatch obj))
  517.    NumberOfLoops (vla-get-NumberOfLoops obj)
  518.    PatternScale (rtos (vla-get-PatternScale obj) 2)
  519.    PatternAngle (rtos (vla-get-PatternAngle obj) 2)
  520.    HatchStyle (vla-get-HatchStyle obj)
  521.    HatchObjectType (vla-get-HatchObjectType obj)
  522.    La (vla-get-Layer obj)
  523.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  524.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  525.    color (vla-get-color obj)
  526.    lineType (vla-get-linetype obj)
  527.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  528.    lineweight (rtos (vla-get-lineweight obj) 2)
  529.    )
  530.     (if (/= 0 NumberOfLoops)
  531.       (progn
  532.     (cond ((= 0 PatternType) (setq PatternType "acHatchPatternTypePreDefined"))
  533.    ((= 1 PatternType) (setq PatternType "acHatchPatternTypeUserDefined"))
  534.    ((= 2 PatternType) (setq PatternType "acHatchPatternTypeCustomDefined"))
  535.    )
  536.     (cond ((= 0 HatchObjectType) (setq HatchObjectType "AcHatchObject"))
  537.    ((= 1 HatchObjectType) (setq HatchObjectType "AcGradientObject"))
  538.    )
  539.     (cond ((= 0 HatchStyle) (setq HatchStyle "acHatchStyleNormal"))
  540.    ((= 1 HatchStyle) (setq HatchStyle "acHatchStyleOuter"))
  541.    ((= 2 HatchStyle) (setq HatchStyle "acHatchStyleIgnore"))
  542.    )
  543.     (setq Loops nil
  544.    k 0)
  545.     (repeat NumberOfLoops
  546.       (vla-getloopat obj k 'OuterLoop)
  547.       (setq Loops (append Loops (list OuterLoop)))
  548.       (setq k (1+ k))
  549.       )
  550.     (setq k 0)
  551.     (foreach Arays Loops
  552.       (if (= (type Arays) 'safearray)
  553.         (progn
  554.    (setq Arayl (GXL-NUM-AX->LISPVALUE Arays))
  555.       (WRITE-LINE  "    (setq HatchobjAray nil)" OpenFile)
  556.       (if (= k 0)
  557.         (progn
  558.    (WRITE-LINE (strcat "   (setq objHatch (vla-AddHatch obj " PatternType " "" PatternName "" " Associative " " HatchObjectType "))") OpenFile)
  559.    (foreach HatchObj Arayl
  560.      (MakeEntity HatchObj);此处嵌套调用容易溢出
  561.      (WRITE-LINE  "(setq HatchobjAray (Append HatchobjAray (list obj1)))" OpenFile)
  562.      )
  563.    (WRITE-LINE  "(setq HatchobjAray (gxl-num-ObjList->AX:Array HatchobjAray))" OpenFile)
  564.    ;(WRITE-LINE  "(vla-AppendOuterLoop objHatch HatchobjAray)" OpenFile)
  565.    (WRITE-LINE "(setq axErr1 (VL-CATCH-ALL-APPLY \'vla-AppendOuterLoop (list objHatch HatchobjAray)))" OpenFile)
  566.    );_ progn
  567.         (progn
  568.    (foreach HatchObj Arayl
  569.      (MakeEntity HatchObj);此处嵌套调用容易溢出
  570.      (WRITE-LINE  "(setq HatchobjAray (Append HatchobjAray (list obj1)))" OpenFile)
  571.      )
  572.    (WRITE-LINE  "(setq HatchobjAray (gxl-num-ObjList->AX:Array HatchobjAray))" OpenFile)
  573.    ;(WRITE-LINE  "(vla-AppendInnerLoop objHatch HatchobjAray)" OpenFile)
  574.    (WRITE-LINE "(setq axErr (VL-CATCH-ALL-APPLY \'vla-AppendInnerLoop (list objHatch HatchobjAray)))" OpenFile)
  575.    );_ progn
  576.         );_ if
  577.       (setq k (1+ k))
  578.       )
  579.         )
  580.       );_ foreach
  581.     (WRITE-LINE   "   (if (not (VL-CATCH-ALL-ERROR-P axErr1))" OpenFile)
  582.     (WRITE-LINE   "     (progn" OpenFile)
  583.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  584.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  585.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  586.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer objHatch "" La "")") OpenFile))
  587.     (WRITE-LINE (strcat "   (vla-put-color objHatch "" (itoa color) "")") OpenFile)
  588.     (if (not(or (= "-1" lineweight)(= "-2" lineweight)(= "-3" lineweight))) (WRITE-LINE (strcat "   (vla-put-layer objHatch "" lineweight "")") OpenFile))
  589.     (WRITE-LINE (strcat
  590.     "   (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  591.     (WRITE-LINE (strcat
  592.     "   (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  593.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  594.     (WRITE-LINE (strcat
  595.     "   (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype objHatch "" lineType ""))") OpenFile)
  596.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale objHatch " LineTypeScale ")") OpenFile)
  597.     (WRITE-LINE (strcat "   (vla-put-PatternScale objHatch " PatternScale ")") OpenFile)
  598.     (WRITE-LINE (strcat "   (vla-put-PatternAngle objHatch " PatternAngle ")") OpenFile)
  599.     (WRITE-LINE (strcat "   (vla-put-HatchStyle objHatch " HatchStyle ")") OpenFile)
  600.     (WRITE-LINE   "     )" OpenFile)
  601.     (WRITE-LINE   "    )" OpenFile)
  602.     );_ progn
  603.       );_ if
  604.     )
  605.    ((= "AcDbBlockReference" ObjectName)
  606.     ;(BlockLisp (vla-get-Name obj))
  607.    
  608.     (setq InsPt (GXL-STR-STOA (gxl-num-ax->lispvalue(vla-get-InsertionPoint obj)))
  609.    BName (vla-get-Name obj)
  610.    Xscale (rtos (vla-get-XScaleFactor obj) 2)
  611.    Yscale (rtos (vla-get-YScaleFactor obj))
  612.    Zscale (rtos (vla-get-ZScaleFactor obj))
  613.    Rotation (rtos (vla-get-Rotation obj))
  614.    La (vla-get-Layer obj)
  615.    Plottable (GXL-STR-STOA (vla-get-Plottable (vla-Item (vla-get-layers *ACDOCUMENT*) La)))
  616.    LaColor (vla-get-color (vla-item (vla-get-Layers *ACDOCUMENT*) La))
  617.    color (vla-get-color obj)
  618.    lineType (vla-get-linetype obj)
  619.    LineTypeScale (rtos (vla-get-LineTypeScale obj))
  620.    )
  621.    ; (WRITE-LINE (strcat "    (if (not (member ""  BName "" (gxl-table "block"))) (BlockLisp "" BName ""))") OpenFile)
  622.     ;(BlockLisp BName)
  623.      (WRITE-LINE (strcat "   (setq obj1 (vla-InsertBlock obj (vlax-3d-point \'"InsPt ") "" BName "" " Xscale " " Yscale " " ZScale " " Rotation "))") OpenFile)
  624.     (if (/= "0" La)(WRITE-LINE (strcat "   (setq objLay (vla-add (vla-get-Layers *ACDOCUMENT*) "" La ""))") OpenFile))
  625.     (WRITE-LINE (strcat "   (vla-put-color (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") "" (itoa Lacolor) "")") OpenFile)
  626.     (if (/= Plottable ":vlax-true")(WRITE-LINE (strcat "   (vla-put-Plottable (vla-item (vla-get-Layers *ACDOCUMENT*) "" La"") " Plottable ")") OpenFile))
  627.     (if (/= "0" La)(WRITE-LINE (strcat "   (vla-put-layer obj1 "" La "")") OpenFile))
  628.     (WRITE-LINE (strcat "   (vla-put-color obj1 "" (itoa color) "")") OpenFile)
  629.     (WRITE-LINE (strcat
  630.     "    (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) "" lineType "" "acadiso.lin")))") OpenFile)
  631.     (WRITE-LINE (strcat
  632.     "    (if (VL-CATCH-ALL-ERROR-P axErr) (setq axErr (VL-CATCH-ALL-APPLY \'vla-load (list (vla-get-Linetypes *ACDOCUMENT*) ""
  633.     lineType "" "EstateCADTools.lin"))))") OpenFile)
  634.     (WRITE-LINE (strcat
  635.     "    (if (not (VL-CATCH-ALL-ERROR-P axErr)) (vla-put-linetype obj1 "" lineType ""))") OpenFile)
  636.     (WRITE-LINE (strcat "   (vla-put-LinetypeScale obj1 " LineTypeScale ")") OpenFile)
  637.     )
  638.    (t nil)
  639.    )
  640.     )
  641.   
  642. ;;;图块定义
  643.   (defun BlockLisp (blkName / EnObj Handle HatchEntList enObj ObjectName NumberOfLoops Loops k OuterLoop Arays Arayl a)
  644.     ;(if (> (vla-get-Count (vla-Item (vla-get-Blocks *AcDocument*) blkName)) 0)
  645.       (progn
  646.    ;(WRITE-LINE (strcat " (if (not (member "" blkName ""( gxl-table "block")))") OpenFile)
  647.    ;(WRITE-LINE  "  (progn" OpenFile)
  648.    (WRITE-LINE   "   (setvar "clayer" "0")" OpenFile)
  649.    (WRITE-LINE (strcat "   (setq obj (GXL-AX:ADDBLOCK \'(0 0 0) "" blkName ""))") OpenFile)
  650.    ;;;遍历blkName,找出Hatch关联的边界实体的Handle,添加到表 HatchEntList 中
  651.    (setq HatchEntList nil)
  652.    ; 不支持 Hatch 实体,Hatch容易溢出
  653.    (vlax-for enObj (vla-Item (vla-get-Blocks *AcDocument*) blkName)
  654.      (setq ObjectName (vla-get-ObjectName enObj)
  655.    Handle (vla-get-Handle enObj)
  656.    )
  657.      (if (= "AcDbHatch" ObjectName)
  658.        (progn
  659.   (setq NumberOfLoops (vla-get-NumberOfLoops enObj))
  660.   
  661.     (setq Loops '()
  662.    k 0)
  663.     (repeat NumberOfLoops
  664.       (vla-getloopat enObj k 'OuterLoop)
  665.       (setq Loops (append Loops (list OuterLoop)))
  666.       (setq k (1+ k))
  667.       )
  668.   (foreach Arays Loops
  669.     ;;;问题出在这儿,溢出?(GXL-NUM-AX->LISPVALUE OuterLoop)
  670.       (if (= (type Arays) 'safearray)
  671.         (progn
  672.    (setq Arayl (GXL-NUM-AX->LISPVALUE Arays))
  673.     (foreach a  Arayl (setq HatchEntList (cons (vla-get-handle a) HatchEntList))(setq a nil))
  674.    )
  675.         )
  676.     )
  677.   
  678.   )
  679.        )
  680.      (setq enobj nil)
  681.     )
  682.    ;(setq HatchEntList nil)
  683.   (vlax-for enObj (vla-Item (vla-get-Blocks *AcDocument*) blkName)
  684.          
  685.     (setq Handle (vla-get-Handle enObj))
  686.    
  687.      (if (not (member Handle HatchEntList)) (MakeEntity enObj))
  688.     (setq enobj nil)
  689.     )
  690.    
  691.   ;(WRITE-LINE "    )" OpenFile)
  692.   ;(WRITE-LINE "   )" OpenFile)
  693.   );_ progn
  694.       ;);_ if

  695.       )
  696.   ;;;本函数添加了图块是否存在的判断
  697.   (defun BlockLisp1 (blkName / EnObj Handle HatchEntList enObj ObjectName NumberOfLoops Loops k OuterLoop Arays Arayl a)
  698.     ;(if (> (vla-get-Count (vla-Item (vla-get-Blocks *AcDocument*) blkName)) 0)
  699.       (progn
  700. ;;;添加图块是否存在判断语句
  701.    (WRITE-LINE (strcat " (if (not (member "" blkName ""( gxl-table "block")))") OpenFile)
  702.    (WRITE-LINE  "  (progn" OpenFile)
  703.    (WRITE-LINE   "   (setvar "clayer" "0")" OpenFile)
  704.    (WRITE-LINE (strcat "   (setq obj (GXL-AX:ADDBLOCK \'(0 0 0) "" blkName ""))") OpenFile)
  705.       ;;;遍历blkName,找出Hatch关联的边界实体的Handle,添加到表 HatchEntList 中
  706.    (setq HatchEntList nil)
  707.    (vlax-for enObj (vla-Item (vla-get-Blocks *AcDocument*) blkName)
  708.      (setq ObjectName (vla-get-ObjectName enObj)
  709.    Handle (vla-get-Handle enObj)
  710.    )
  711.      (if (= "AcDbHatch" ObjectName)
  712.        (progn
  713.   (setq NumberOfLoops (vla-get-NumberOfLoops enObj))
  714.     (setq Loops '()
  715.    k 0)
  716.     (repeat NumberOfLoops
  717.       (vla-getloopat enObj k 'OuterLoop)
  718.       (setq Loops (append Loops (list OuterLoop)))
  719.       (setq k (1+ k))
  720.       )
  721.   (foreach Arays Loops
  722.     (if (= (type Arays) 'safearray)
  723.       (progn
  724.       (setq Arayl (GXL-NUM-AX->LISPVALUE Arays))
  725.     (foreach a  Arayl (setq HatchEntList (cons (vla-get-handle a) HatchEntList))(setq a nil))
  726.       )
  727.       )
  728.     )
  729.   
  730.   )
  731.        )
  732.      (setq enobj nil)
  733.     )
  734.    (vlax-for enObj (vla-Item (vla-get-Blocks *AcDocument*) blkName)
  735.     (setq Handle (vla-get-Handle enObj))
  736.     (if (not (member Handle HatchEntList)) (MakeEntity enObj))
  737.      (setq enobj nil)
  738.     )
  739.    
  740.   (WRITE-LINE "    )" OpenFile)
  741.   (WRITE-LINE "   )" OpenFile)
  742.   );_ progn
  743.       ;);_ if

  744.       )
  745.   ;;;主程序
  746.   ;(setierr)
  747.   ;(setq OpenFile (open "MakeBlock.Lsp" "w"))
  748.   (setq OpenFile (open (setq tmp_Fn (vl-filename-mktemp)) "w"))
  749.   ;(setq enss (ssget "x" '((0 . "insert"))))
  750.   ;;;剔除无名块
  751.   (setq BlockNameList (VL-REMOVE-IF '(lambda (x) (= "*U" (substr x 1 2))) (vl-sort (GXL-TABLE "block") '<)))
  752.   (if (not BlockNameList)(progn (alert "图形中没有图块可供生成代码!") (abcdefg)))
  753.   (setq ;enss (GXL-SEL-SS->LIST enss)
  754. mk 0
  755. mn 0)
  756.   ;(WRITE-LINE "(defun Create_block0 (Name / obj obj1)" OpenFile)
  757.   ;(WRITE-LINE " (cond " OpenFile)
  758.   (foreach blockName BlockNameList;enblk enss
  759.     (setq blockName1 (gxl-Str-Subst "]" ")" (gxl-Str-Subst "[" "(" blockName)))
  760.      (WRITE-LINE (strcat "(defun MakeBlock-" blockName1 " (/ obj obj1 obj2 objHatch HatchobjAray )") OpenFile)
  761.    ;;;列出嵌套子块,由低到高定义块实体
  762.     (setq BL (ListMutiBlock blockName))
  763.     (if bl (mapcar '(lambda (x) (BlockLisp1 x)) BL))
  764.     ;;;定义非块实体
  765.     (BlockLisp blockName)
  766.     (WRITE-LINE "  )" OpenFile)
  767.     );_ Foreach
  768.   
  769.   ;;;定义调用函数 gxl-Blk-Check
  770.   ;|
  771.   (WRITE-LINE "(defun gxl-Blk-Check (B_Name / curlay B_Name1)" OpenFile)
  772.   (WRITE-LINE "  (setq B_Name1 (gxl-Str-Subst "]" ")" (gxl-Str-Subst "[" "(" B_Name)))" OpenFile)
  773.   (WRITE-LINE "  (setq curlay (getvar "Clayer"))" OpenFile)
  774.   (WRITE-LINE "  (if (not (member B_Name (GXL-TABLE "block")))" OpenFile)
  775.   (WRITE-LINE "    (progn" OpenFile)
  776.   (WRITE-LINE "(if (or (= \'USUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))" OpenFile)
  777.   (WRITE-LINE "        (= \'SUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))" OpenFile)
  778.   (WRITE-LINE "      )" OpenFile)
  779.   (WRITE-LINE "    (eval (read (strcat "(MakeBlock-" B_Name1 ")"))))" OpenFile)
  780.   (WRITE-LINE "      )" OpenFile)
  781.   (WRITE-LINE "    )" OpenFile)
  782.   (WRITE-LINE "  (setvar "clayer" curlay)" OpenFile)
  783.   (WRITE-LINE "  B_Name" OpenFile)
  784.   (WRITE-LINE "  )" OpenFile)
  785.   |;
  786.     (close OpenFile)
  787.   ;(startapp "notepad.exe" "MakeBlock.Lsp")
  788.   (startapp "notepad.exe" tmp_Fn)
  789.   ;(reerr)
  790.   )
  791. ;;; c:BlockIn 在图形中插入"E:\\lisp\\symbol"目录下的全部图形,
  792. (defun c:BlockIn (/ f)
  793.   (setierr)
  794.   (foreach f (vl-sort (gxl-file-Dos_dir "E:\\lisp\\symbol\\*.dwg") '<)
  795.     (command "-insert" (strcat "E:\\lisp\\symbol\" f) '(0 0 0) 1 1  0)
  796.     )
  797.   (reerr)
  798.   )
  799. ;;; gxl-Blk-Check 检查定义图块
  800. (defun gxl-Blk-Check (B_Name / curlay B_Name1)
  801.   (setq B_Name1 (gxl-Str-Subst "]" ")" (gxl-Str-Subst "[" "(" B_Name)))
  802.   (setq curlay (getvar "Clayer"))
  803.   (if (not (member B_Name (GXL-TABLE "block")))
  804.     (progn
  805.       (if (or (= 'USUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))
  806.        (= 'SUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))
  807.        )
  808. (eval (read (strcat "(MakeBlock-" B_Name1 ")"))))
  809.       )
  810.     )
  811.   (setvar "clayer" curlay)
  812.   B_Name
  813.   )

代码中涉及到一些自定义公用函数,需要前贴中附件打包的函数支持!
回复 支持 2 反对 0

使用道具 举报

发表于 2010-7-22 09:07:00 | 显示全部楼层

使用程序出现下列问题是怎么回事?cad版本2008

命令: blocktolisp
; 错误: ActiveX 服务器返回错误: 无效索引。

回复 支持 0 反对 1

使用道具 举报

发表于 2021-10-29 08:47:55 | 显示全部楼层
加载后出现此软件的使用未获得软件作者的授权呀     说QQ联系 919420899
发表于 2010-7-20 18:10:00 | 显示全部楼层

哇!不是源码啊!

只能纯欣赏了!

感谢楼主分享!

 楼主| 发表于 2010-7-22 11:21:00 | 显示全部楼层
我机器未装2008版,所以程序未经2008版本测试,在2000~2005有效!等我装了08版我会再调试一下!
 楼主| 发表于 2010-7-25 18:53:00 | 显示全部楼层
本帖最后由 Gu_xl 于 2013-3-14 12:33 编辑

2010年7月25日对块中含PolyLine线进行了修改

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2010-8-2 06:32:00 | 显示全部楼层

Block 自动转为Lisp源代码 下载来看看学习学习

不知道在2006上能否用

谢谢楼主

发表于 2010-8-2 14:49:00 | 显示全部楼层

dear sir

plz shere sample file

 

发表于 2010-8-2 22:49:00 | 显示全部楼层
看起来是很神奇的,明天我试试
发表于 2010-8-6 11:04:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2010-8-9 13:23:00 | 显示全部楼层
如果能支持高版本的CAD就更好了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-12-29 15:20 , Processed in 0.235392 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表