乐筑天下

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

[编程交流] 如何预览图案?

[复制链接]

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 15:32:16 | 显示全部楼层 |阅读模式
如何预览图案?
高亮显示选择行并在修改行后刷新。
图案修改。rar公司
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 15:50:54 | 显示全部楼层
  1. (defun c:pm()
  2. ;-------------------------
  3. (defun parsestr->lst (str / LST POS str)
  4.         (while (setq pos (vl-string-search "," str))
  5.                 (setq lst (cons (vl-string-left-trim " "(substr str 1 pos)) lst)
  6.                         str (substr str (+ pos 2))
  7.                         )
  8.         )
  9.         (if (> (strlen str) 0)
  10.                 (setq lst (cons (vl-string-left-trim " " str) lst))
  11.         )
  12.         (reverse lst)
  13. )
  14. ;-------------------------
  15. ;(joinlst->str (list "1" "2" "3" "4" "5" "6"))
  16. (defun joinlst->str (lst / LST POS str)
  17.         (setq str "")
  18.         (while lst
  19.                 (setq x (car lst))
  20.                 (if (setq lst(cdr lst))
  21.                         (setq str (strcat str x ","))
  22.                         (setq str (strcat str x))
  23.                 )
  24.         )
  25.         str
  26. )
  27. ;-------------------------
  28. (defun subst-index(var n lst / i)
  29.         (setq i -1)
  30.         (mapcar '(lambda(x) (if (= n (setq i (1+ i))) var x)) lst)
  31. )
  32. ;-----------DELETE A ITOM--------------
  33. ;(delete-index 1 '((1 2 3) (4 5 6)(7 8 9)))
  34. (defun delete-index(n lst / i)
  35.         (setq i -1)
  36.         (vl-remove-if '(lambda(x) (= (setq i (1+ i)) n)) lst)
  37. )
  38. ;-----------INSERT A ITOM--------------
  39. ;(add-index "A" -1 '(0 1 2 3 4 5))
  40. (defun add-index(var n lst / len i newlst)
  41.         (setq len (length lst))
  42.         (cond
  43.                 ((< n 0)
  44.                         (setq newlst (cons var lst))
  45.                 )
  46.                 ((>= n len)
  47.                         (setq newlst (reverse(cons var (reverse lst))))
  48.                 )
  49.                 (t
  50.                         (setq i -1 newlst nil)
  51.                         (foreach itom lst
  52.                                 (if (= n (setq i (1+ i)))
  53.                                         (setq newlst (cons itom newlst)
  54.                                                 newlst (cons var newlst)
  55.                                         )
  56.                                         (setq newlst (cons itom newlst))
  57.                                 )
  58.                         )
  59.                         (setq newlst (reverse newlst))
  60.                 )
  61.         )
  62.         newlst
  63. )
  64. ;-------------------------
  65. (defun LM:editbox ( str / han )
  66.         (and (< 0 (setq han (load_dialog "acad")))
  67.                 (new_dialog  "acad_txtedit" han)
  68.                 (set_tile    "text_edit"    str)
  69.                 (action_tile "text_edit" "(setq str $value)")
  70.                 (if (zerop (start_dialog)) (setq str nil))
  71.         )
  72.         (if (< 0 han) (unload_dialog han))
  73.         str
  74. )
  75. ;-------------------------
  76. (defun readpatfile(file / files fn PatternList pat x fn)
  77.         (if (and (setq files(findfile file))
  78.                         (setq fn (open  files "r"))
  79.                 )
  80.                 (progn
  81.                         (setq PatternList NIL pat nil)
  82.                         (while (setq x (read-line fn))
  83.                                 (cond
  84.                                         ((wcmatch X "`**")
  85.                                                 (if pat
  86.                                                         (setq PatternList (cons (reverse pat) PatternList))
  87.                                                 )
  88.                                                 (setq pat nil
  89.                                                         pat (cons x pat)
  90.                                                 )
  91.                                         )
  92.                                         ((wcmatch X "#*#*#*#*")
  93.                                                 (setq pat(cons x pat))
  94.                                         )
  95.                                         (t nil)
  96.                                 )
  97.                         )
  98.                         (setq PatternList (cons (reverse pat) PatternList))
  99.                         (close fn)
  100.                 )
  101.         )
  102.         (reverse PatternList)
  103. )
  104. ;-------------------------
  105. (defun show_list(key newlist)
  106.         (start_list key)
  107.         (mapcar 'add_list newlist)
  108.         (end_list)
  109. )
  110. ;-------------------------
  111. (defun act_open()
  112.         (if (setq patfile(getfiled "SELECT A FILE(.PAT) TO OPEN" (get_tile "patfile") "pat" 2))
  113.                 (progn
  114.                         (setq PatternList (readpatfile patfile))
  115.                         (show_list "patnamelst" (mapcar 'car PatternList))
  116.                         (show_list "patterninfo" nil)
  117.                 )
  118.         )
  119. )
  120. (defun act_save( / fn)
  121.         (if (and (setq patfile(getfiled "SELECT A FILE(.PAT) TO SAVE" (get_tile "patfile") "pat" 2))
  122.                         (setq fn (open  patfile "w"))
  123.                 )
  124.                 (progn
  125.                         (foreach x PatternList
  126.                                 (foreach y x
  127.                                         (write-line y fn)
  128.                                 )
  129.                                 (write-line ";-----------------" fn)
  130.                         )
  131.                         (close fn)
  132.                 )
  133.         )
  134. )
  135. ;-----------SSGET TO PATTERN--------------
  136. ;------------getpatlinestr-------------
  137. (defun getpatlinestr(/ patlinestr PT0 startpt angpt deltax deltay ang originx originy i ptn0 ptn1 dash)
  138.         (if (and (setq PT0 (getpoint"\n Base point:"))
  139.                         (setq startpt(getpoint"\n Start point:"))
  140.                         (setq angpt(getpoint startpt "\n Angle:"))
  141.                         (or(setq deltax (getdist"\n deltaX<0>:"))(setq deltax 0))
  142.                         (or(setq deltay (getdist"\n deltaY<0>:"))(setq deltay 0))
  143.                 )
  144.                 (progn
  145.                         (setq ang (angtos(angle startpt angpt)0 4)
  146.                                 originx (rtos(- (car startpt) (car pt0)))
  147.                                 originy (rtos(- (cadr startpt) (cadr pt0)))
  148.                                 patlinestr (strcat ang "," originx "," originy "," (rtos deltax) "," (rtos deltax))
  149.                                 )
  150.                         (setq i 1 ptn0 startpt)
  151.                         (while (setq ptn1 (getpoint ptn0 (strcat "\n Get dash" (if (= (rem (setq i (1+ i)) 2)0) "CONTINOUS" "NONE")"distance<EXIT>:")))
  152.                                 (setq dash (rtos(distance ptn0 ptn1))
  153.                                         patlinestr (strcat patlinestr "," dash)
  154.                                         ptn0 ptn1
  155.                                         )
  156.                         )
  157.                 )
  158.         )
  159.         patlinestr
  160. )
  161. ;----------DELETE PATTERN---------------
  162. (defun act_delpattern()
  163.         (if (and (setq patlstn(get_tile "patnamelst"))
  164.                         (setq patlstn (atoi patlstn))
  165.                 )
  166.                 (progn
  167.                         (setq PatternList (delete-index patlstn PatternList))
  168.                         (show_list "patnamelst" (mapcar 'car PatternList))
  169.                         (set_tile "patnamelst" (itoa patlstn))
  170.                 )
  171.         )
  172. )
  173. ;----------search pattern---------------
  174. (defun act_searchpattern(/ searchstr)
  175.         (if (/= (setq searchstr(get_tile "searchstr"))"")
  176.                 (progn
  177.                         (setq tempatlst (vl-remove-if-not '(lambda(x)(wcmatch (car x) (strcat"*" searchstr "*")))PatternList))
  178.                         (show_list "patnamelst" (mapcar 'car tempatlst))
  179.                         (set_tile "patnamelst" "0")
  180.                 )
  181.         )
  182. )
  183. ;----------ADD ONE LINE---------------
  184. (defun act_addline()
  185.         (if (setq patterninfon (get_tile "patterninfo"))
  186.                 (setq patterninfon (atoi patterninfon))
  187.                 (setq patterninfon (length patterninfo))
  188.         )
  189.         (setq patterninfo (add-index "Angle,StartX,StartY,DeltaX,DeltaY" patterninfon patterninfo))
  190.         (show_list "patterninfo" patterninfo)
  191.         (set_tile "patterninfo" (itoa (1+ patterninfon)))
  192.         (act_patvauelst)
  193. )
  194. ;----------DELETE ONE LINE---------------
  195. (defun act_deline()
  196.         (if (and (setq patterninfon (get_tile "patterninfo"))
  197.                         (setq patterninfon (atoi patterninfon))
  198.                         )
  199.                 (progn
  200.                         (setq patterninfo (delete-index patterninfon patterninfo))
  201.                         (show_list "patterninfo" patterninfo)
  202.                         (set_tile "patterninfo" (itoa patterninfon))
  203.                         (if patterninfo (act_patvauelst))
  204.                 )
  205.                 (alert "NEED TO SELECT A LINE.")
  206.         )
  207. )
  208. ;----------COPY TO recovery---------------
  209. (defun act_copyline()
  210.         (if (and (setq patterninfon (atoi(get_tile "patterninfo")))
  211.                         (setq patlinestr (nth patterninfon patterninfo));该行的字符串
  212.                 )
  213.                 (progn
  214.                         (setq recoverylst (reverse(cons patlinestr (reverse recoverylst))))
  215.                         (show_list "recoverylst" recoverylst)
  216.                         (set_tile "recoverylst" (itoa (1-(length recoverylst))))
  217.                 )
  218.                 (alert "NEED TO SELECT A LINE.")
  219.         )
  220. )
  221. ;----------recovery A LINE---------------
  222. (defun act_recovery()
  223.         (if (and
  224.                         (setq patterninfon (get_tile "patterninfo"))
  225.                         (setq patterninfon (atoi patterninfon))
  226.                         (setq recoverylstn (atoi(get_tile "recoverylst")))
  227.                         (setq patlinestr (nth recoverylstn recoverylst))
  228.                 )
  229.                 (progn
  230.                         (setq patterninfo (add-index patlinestr patterninfon patterninfo))
  231.                         (show_list "patterninfo" patterninfo)
  232.                         (set_tile "patterninfo" (itoa patterninfon))
  233.                 )
  234.                 (alert "Need to select a line in recovery and Selece insert position.")
  235.         )
  236. )
  237. ;----------DELETE A LINE IN recovery---------------
  238. (defun act_recoverydel()
  239.         (if (and (setq recoverylstn (get_tile "recoverylst"))
  240.                         (setq recoverylstn (atoi recoverylstn))
  241.                 )
  242.                 (progn
  243.                         (setq recoverylst (delete-index recoverylstn recoverylst))
  244.                         (show_list "recoverylst" recoverylst)
  245.                         (if recoverylstn (set_tile "recoverylst" (itoa recoverylstn)))
  246.                 )
  247.                 (alert "NEED TO SELECT A LINE.")
  248.         )
  249. )
  250. ;----------CLEAN recovery---------------
  251. (defun act_recoveryclean()
  252.         (setq recoverylst nil)
  253.         (show_list "recoverylst" recoverylst)
  254. )
  255. ;-------------------------
  256. (defun act_patnamelst()
  257.         (setq patlstn (atoi(get_tile "patnamelst"))
  258.                 patterninfo (nth patlstn PatternList)
  259.                 )
  260.         (show_list "patterninfo" patterninfo)
  261.         (set_tile "patterninfo" "0")
  262.         (act_patvauelst)
  263. )
  264. ;-------------------------
  265. (defun act_patvauelst( / leard)
  266.         (setq patterninfon (atoi(get_tile "patterninfo"))
  267.                 patlinestr (nth patterninfon patterninfo)
  268.                 infolst (parsestr->lst patlinestr)
  269.                 )
  270.         (if (wcmatch patlinestr "`**")
  271.                 (progn
  272.                         (mode_tile "getinfo" 1)
  273.                         (setq leard (list "PatternName" "Description"))
  274.                         )
  275.                 (progn
  276.                         (mode_tile "getinfo" 0)
  277.                         (setq leard (list "angle" "originX" "originY" "deltaX" "deltaY" "dash1" "dash2" "dash3" "dash4" "dash5" "dash6" "dash7" "dash8" "dash9")))
  278.         )
  279.         (setq infolst (mapcar '(lambda(x y)(cons x y)) leard infolst))
  280.         (show_list "infolst" (mapcar '(lambda (x) (strcat (car x)"\t= " (cdr x)))infolst))
  281. )
  282. ;-------------------------
  283. (defun act_infolst( / var str)
  284.         (if (and (setq var (nth infolstn infolst))
  285.                         (setq str (LM:editbox (cdr var)))
  286.                 )
  287.                 (progn
  288.                         (setq infolst (subst-index (cons (car var) str) infolstn infolst);
  289.                                 patlinestr (joinlst->str (mapcar 'cdr infolst));
  290.                                 patterninfo (subst-index patlinestr patterninfon patterninfo);
  291.                                 PatternList (subst-index patterninfo patlstn PatternList);
  292.                                 )
  293.                         (show_list "patterninfo" patterninfo)
  294.                         (set_tile "patterninfo" (itoa patterninfon))
  295.                         (show_list "infolst" (mapcar '(lambda (x) (strcat (car x)"\t= " (cdr x)))infolst))
  296.                         (set_tile "infolst" (itoa infolstn))
  297.                 )
  298.         )
  299. )
  300. ;-------------------------
  301. (defun showdcl()
  302.         (if (and(setq dclfile(findfile "PatternModify.dcl"))
  303.                         (>= (setq DCLID (load_dialog dclfile)) 0)
  304.                 )
  305.                 (progn
  306.                         (new_dialog "pat" DCLID)
  307.                         (set_tile "patfile" patfile)
  308.                         (if PatternList (show_list "patnamelst" (mapcar 'car PatternList)))
  309.                         (if patterninfo(show_list "patterninfo" patterninfo))
  310.                         (if recoverylst(show_list "recoverylst" recoverylst))
  311.                         (if infolst(show_list "infolst" (mapcar '(lambda (x) (strcat (car x)"\t= " (cdr x)))infolst)))
  312.                         ;(if dcldata (setdcldata))
  313.                         (action_tile "open" "(act_open)")
  314.                         (action_tile "save" "(act_save)")
  315.                         (action_tile "delpattern" "(act_delpattern)")
  316.                         (action_tile "searchbut" "(act_searchpattern)")
  317.                         (action_tile "addline" "(act_addline)")
  318.                         (action_tile "deline" "(act_deline)")
  319.                         (action_tile "copyline" "(act_copyline)")
  320.                         (action_tile "recovery" "(act_recovery)")
  321.                         (action_tile "recoverydel" "(act_recoverydel)")
  322.                         (action_tile "recoveryclean" "(act_recoveryclean)")
  323.                         (action_tile "patnamelst" "(act_patnamelst)")
  324.                         (action_tile "patterninfo" "(act_patvauelst)")
  325.                         (action_tile "infolst" "(setq infolstn (atoi $value)) (if(= $reason 4) (act_infolst))")
  326.                         ;(action_tile "open" "(act_openpatfile)")
  327.                         (action_tile "cancel" "(done_dialog)")
  328.                         (action_tile "addpattern" "(done_dialog 11)")
  329.                         (action_tile "getinfo" "(done_dialog 12)")
  330.                         ;(action_tile "accept" "(getdcldata)(done_dialog 0)")
  331.                         (setq return (start_dialog))
  332.                         (cond
  333.                                 ((= return 11)
  334.                                         (princ)
  335.                                 )
  336.                                 ((= return 12)
  337.                                         (if (setq patlinestr (getpatlinestr))
  338.                                                 (setq patterninfo (add-index patlinestr patterninfon patterninfo))
  339.                                         )
  340.                                         (showdcl)
  341.                                 )
  342.                                 (t nil)
  343.                         )
  344.                 )
  345.         )
  346. )
  347. ;-------------------------
  348. (if (not PatternList)
  349.         (setq patfile (findfile "acadiso.pat")
  350.                 PatternList (readpatfile patfile )
  351.         )
  352. )
  353. (showdcl)
  354. )

 
;----------------------
  1. /*★★★★★ListDCL @ fsxm.mjtd.com★★★★★*/
  2. pat:dialog {
  3.    label = "Pattern Modify" ;
  4.    :row {
  5.        :button {
  6.                                         key = "open" ;
  7.            fixed_width = true ;
  8.            label = "Open" ;
  9.        }
  10.        :button {
  11.            fixed_width = true ;
  12.                                         key = "save" ;
  13.            label = "Save" ;
  14.        }
  15.        :edit_box {
  16.                             key = "patfile" ;
  17.            width = 100 ;
  18.        }
  19.        :button {
  20.            fixed_width = true ;
  21.                                         key = "help" ;
  22.            label = "Help" ;
  23.        }
  24.        :button {
  25.            fixed_width = true ;
  26.            is_cancel = true ;
  27.            label = "Cancel" ;
  28.        }
  29.    }
  30.    :row {
  31.        :boxed_column {
  32.            label = "Pattern List" ;
  33.            children_fixed_height = true ;
  34.            :row {
  35.                fixed_height = true ;
  36.                :button {
  37.                    fixed_width = true ;
  38.                                                                         key = "addpattern" ;
  39.                    label = "Add Pattern" ;
  40.                }
  41.                :button {
  42.                    fixed_width = true ;
  43.                                                                         key = "delpattern" ;
  44.                    label = "Delete Pattern" ;
  45.                }
  46.            }
  47.            :row {
  48.                fixed_height = true ;
  49.                :edit_box {
  50.                    key = "searchstr" ;
  51.                }
  52.                :button {
  53.                    key = "searchbut" ;
  54.                    fixed_width = true ;
  55.                    label = "Search" ;
  56.                }
  57.            }
  58.            :list_box {
  59.                height = 35 ;
  60.                key = "patnamelst" ;
  61.                width = 30 ;
  62.            }
  63.        }
  64.        :boxed_column {
  65.            children_fixed_height = true ;
  66.            label = "Pattern Info" ;
  67.            :row {
  68.                fixed_height = true ;
  69.                :button {
  70.                    fixed_width = true ;
  71.                                                                         key = "addline" ;
  72.                    label = "Add Line" ;
  73.                }
  74.                :button {
  75.                    fixed_width = true ;
  76.                                                                         key = "deline" ;
  77.                    label = "Dele Line" ;
  78.                }
  79.                :button {
  80.                    fixed_width = true ;
  81.                                                                         key = "copyline" ;
  82.                    label = "Copy to Recovery" ;
  83.                }
  84.            }
  85.            :list_box {
  86.                key = "patterninfo" ;
  87.                width = 45 ;
  88.                height = 24 ;
  89.            }
  90.            :image {
  91.                key = "img" ;
  92.                                                         aspect_ratio = 0.6 ;
  93.                color = -2 ;
  94.                width = 45 ;
  95.            }
  96.        }
  97.        :column {
  98.            :boxed_column {
  99.                label = "Recovery" ;
  100.                :row {
  101.                    fixed_height = true ;
  102.                    :button {
  103.                        fixed_width = true ;
  104.                                                                                         key = "recovery" ;
  105.                        label = "Recovery Line" ;
  106.                    }
  107.                    :button {
  108.                        fixed_width = true ;
  109.                                                                                         key = "recoverydel" ;
  110.                        label = "Delete Line" ;
  111.                    }
  112.                    :button {
  113.                        fixed_width = true ;
  114.                                                                                         key = "recoveryclean" ;
  115.                        label = "Clean" ;
  116.                    }
  117.                }
  118.                :list_box {
  119.                    key = "recoverylst" ;
  120.                                                                         fixed_height = true ;
  121.                }
  122.            }
  123.            :boxed_column {
  124.                children_alignment = centered ;
  125.                label = "Modify line info" ;
  126.                                                         :button {
  127.                    fixed_width = true ;
  128.                                                                         key = "getinfo" ;
  129.                    label = "Get Line Info" ;
  130.                }
  131.                :list_box {
  132.                    key = "infolst" ;
  133.                                                                         tabs = "10" ;
  134.                                                                         height = 23 ;
  135.                }
  136.            }
  137.        }
  138.    }
  139. }
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 15:57:36 | 显示全部楼层
就像这样
163219khbwawjpbaztlntw.jpg
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 16:05:35 | 显示全部楼层
我很欣赏语言差异,但“帮助”中有关于Pat文件详细信息含义的详细信息。我会尽量找到我有旧的纸质副本,以便更快地找到像这样的东西,但在工作中。
 
https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/Creating-new-Custom-Hatch-patterns.html
 
在添加acad之前,我建议使用lisp通过尝试绘制pat文件来检查pat文件。pat已经有一段时间了,很确定可以加载自定义。pat等
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 16:16:57 | 显示全部楼层
@贝尔克斯:
DCL有限。没有专门用于此目的的瓷砖。但您可以使用vector_image函数在DCL图像块中绘制向量。因此,应该可以显示填充图案。不过,这需要一些工作。
 
也许值得一看OpenDCL,它确实有一个图案填充控件。
回复

使用道具 举报

3

主题

8

帖子

5

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-5 16:25:00 | 显示全部楼层
哈哈,找一个图案制作工具,我想要的是它的外观。
163222dtsbhns3ustbx8rt.jpg
回复

使用道具 举报

18

主题

1529

帖子

973

银币

中流砥柱

Rank: 25

铜币
649
发表于 2022-7-5 16:35:28 | 显示全部楼层
所以:使用OpenDCL。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-14 21:04 , Processed in 3.752990 second(s), 69 queries .

© 2020-2025 乐筑天下

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