乐筑天下

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

[编程交流] 块间距lisp

[复制链接]

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:22:10 | 显示全部楼层 |阅读模式
大家早上好。
 
我有一个关于Lisp程序的问题。我想知道这是可能的,还是真的很好。
 
我在一家太阳能电池板支架公司工作,我们使用CAD在屋顶上填充模块。为这些模块分配颜色,以确定镇流器重量。每种颜色都有一个特定的镇流器块间距,该间距随作业而变化。镇流器块、模块和着色区都在块上,在我们所有的图纸中都保持不变。
 
目前,我们将每个区块复制并粘贴到我们的图纸中,一些图纸有3000多个区块。这非常耗时,我知道有更好的方法。。。。一些是如何做到的。是否有一种方法可以让例程提示用户每个区域的间距,并用压载块填充布局;一次填充一行或整个图形。
 
提前谢谢你。
回复

使用道具 举报

15

主题

315

帖子

361

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 17:25:54 | 显示全部楼层
这听起来像是ARRAY命令的作业。
我有什么遗漏吗?
 
(它询问x间距、y间距,然后复制/粘贴客户端选择的内容)
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:30:34 | 显示全部楼层
阵列无法工作,因为每个分区的间距不同。就好像我需要一个“智能”阵列,可以确定它填充的区域;这有意义吗。我将在下面附上一张图片,展示区域是如何变化的。如您所见,简单的array命令将不起作用;除非我遗漏了什么。

                               
登录/注册后可看大图
[img]https://www.cadtutor.net/forum/image/png;base64,Ivborw0kgoaaaansuheugaaaoqaaaaaab5caiaacmzrphaaapjeleqvr4no2dtzlylbdhcxv2s5y7uhlpwyxz2luyzulz2fz5t0e9sk8c94hw/qdbhpmnfdbkhaf78aalqznif2t23v9/MHnv/d8/Pl6PiauryafzZbPdhePr7Q5f2h+Om+3udl7ijemmxlulrihaify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ll5rxocllmw7kvip3ydss6savsvsvsvsvsvsvsvsvsvaqw27ffqnngxb07heu9ytuktuxgaljnx36jzututos1jdv1htwww1byzm7aubm+unxkps2www5pq+kfwornmzzzz wzbz20b+/cw5pji40ed4a1mda+ANb2sX8DsxUZGxn/3ac9q3olb8ycavj2c/dbF1OjHBEci+98LkBFUraylgDq9XYL9psdYZGTEh1Q54bUKGkuYzFsArb+y1bbnufkharkzphhbBeuorrrjnbrgquvbkqunlewnyxmswkpz2zpkomlwfgjxbzf7ujnzxum6z5riweq678melppz/kOMpZ9kUVYKXPTpWVDlBMiqW5iFlt7Ou68z5qd8zPZZ+VCwxgZT+dL29aVOO0at9yywY/TosKsQ/mtceetkieze26ay5ae89ln5uldmblvshjlkgzajztixy/vi1qytaxjo4swfrzkdmyxr2e1z8qfhmeyskgwlgurt0hr5cuh5ch5chz KGH2S2SS3CHBOFTLZGA4I5758VXC9LM50NBBxKFhsRefPanH1QR8SJPCWGQQC6G9XSYPMQMJUMVYMAV8XHLN69NMJBLHYZ+MQZ9XY6MBXYPUWAXOIKCEPN1ABRV1U+sF7qtVz3cQI+eXr0m9e99i98iA9rij2U61kJLrPjb0AqybgC53BcmSK8XdUGlhL1yRCCC+cfy8khiryireln77iywmsitmvw1xzyugollncwaom+EJn4PVSpJLyuNE6s1BKQY0WWJ80fA6fGhlfu8/qmndqvuais5xggfbchtwtrjpwoppyfmuj+dsfwrpygg7hrqeswtreyin8ukdxuqevw6/sbbnq6ygj3as6prknimy+jQMbfus1cEPa1FtNkpJdb9mg5CMqfGU/FCg/bkkk BST/0+d/Ekghajqxa2uwcduhcs90n1ujja2paj7pbf2rhcnrvsmrvpvmovngfgsvqxk+THi5+6waKZWZeAtiZJznPmv2jbRFRuGlpo9b2/dz5t6t1zgsjmzjlyukc8l2k54b0o6bbFb5RtoiI/fS/nD0nv8+PQXRACMV0IQ3GFYUKFJXCpVehlfcaxe7DBT3VV7HTPLTQHrgyojmxazBM8C/Sr7d7DawV9y6akVuW2ersq2KncN0N+fK1PLF7J/fxWQOr1dj7afINT6N4rdlGApzpb1wHPOQiuxEEqVLKiGs5MRwUw2o49rjPSzHbmP1bPDeAu94oowGsa4qpnQDyuVT+l/0X976w/V1JP3HxVNUNXP7C+CNczp6+3P6 UPJ4321043R+O8fjr+we+FE5Dvt7up/MF1kpKns4X3FywcDpfTufL1/eP936z3b1cBysxx5v9LbAG1NzHZ/GB2BRE7TFBPVWMHMMES4TQWS2QF/ZRYMoE1bLVEWMOUCH9fLoVJXgasmpXHDPP+cLze7jEoxhzCXjwOCMLTcAzBdf+ohSUhrJvt7nq77w/HAOv+caynlhrwcsrndesbpbgfizf3z8bykhncuqrkewvahlhtnqbi4khid11uryppnc+vfPIHc75QhWJGZ/ooiamy2ssrausfiiix6dybrhfe6w4g68xed9tlaimtril4q1k6zflyxzzzzzlyyurylwxkrj6sx0mk9+k+txuq1npsd2txtjmn8gvjlpgty1ralrwmfd02ksmaxptyspugxnor2b/aaz5jazmzm Oxgtr6grjei//1ielarr2isapixyyrlyxqxjwxjse1vcdnoh6tcb/asxEYtJIeyvKWqUNVTsjNGQIK9lQGO6Kx8Zgx+CXcctgxdUgrKXPaiT9htdJlU30lS/2hrWoiokzXWHFZgXjwmNjsMHkN70FsJIqR1hLn9XI+Q2vr7BaOTMSVuGHCZr1HsQmuaKFles8d4MVy9j+4H2Ftc6ZOURW5b88wO/SZbDiQhBWzgoX22W/ZU1XWOucGQwrztn1HjQirCeF
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:32:46 | 显示全部楼层
Here is an example of it. It is almost like i need a smart array to determine what zone the array is populating. Any suggestions?    182217ykhhbht35oqath9h.png
回复

使用道具 举报

15

主题

315

帖子

361

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 17:35:35 | 显示全部楼层
Let me get an idea of what exacly you have to do.
 
When you start drawing, those rectangles with colors are already there, and you have to fill in those small, vertical rectangles.
example: row 30: the non-hatched region (between the two green regions) requires a ballast every 1200 length units; while the red region on row 29 requires a ballast every 600 units.
Right?
 
What do those colored rectangles look like?  Are those blocks?  Is this hatch filled in manually or is there some button (visibility parameter) to change the color of the hatch? Do they contain an attribute with the spacing value ? ...  Anything like that?
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:39:55 | 显示全部楼层
 
When i start drawing I only have the roof layout. I have to put the panels on the roof layout (the panels are blocks), and then colour it to our engineering standards. The hatched colouring is a block, so are the panels (each colour, red, blue green yellow have their own block and own layer). The small rectangles are ballasts and those are blocks as well. Each ballast block will have its own spacing which is dependent on the zone it is it (both front and rear block have different spacing). ex. yellow zone could have 800mm rear 950mm front, blue 1125mm front 1875mm rear.
回复

使用道具 举报

15

主题

315

帖子

361

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 17:42:21 | 显示全部楼层
I think this is about what you need.
Can you arrange your blocks to have the items I'm reading?  
Or what exactly do you have; what do your blocks look like?
 
It works for 1 row (at a time); I expect each row to be horizontal (same y-point); you can always rotate everything later.
 
--------
  1. ; load extra recources(vl-load-com)(defun ballast ( / blocks x_values sorted_indexes block spacing x_pointer lft rgt width_panel y_value)  (princ "\nSelect the solar panel blocks (cross select)") (setq    i 0   spacing 0.0   x_pointer 0.0                                                       ;; x_pointer is like the needle of a turn table.  We set it to the x of the left panel block, then it only increases untill we get to the right panel    x_values (list)   blocks (ssget ":N"     ;; client makes a cross select     (list        (cons 0 "INSERT")     )   ) ) ;; we read the y-value of the first panel (setq y_value (nth 2 (assoc 10 (entget (ssname blocks 0)))  ))  ;; we make an array (list) containing the x-value of the insert point  (repeat (sslength blocks)   (setq x_values (append x_values (list     (cadr (assoc 10 (entget (ssname blocks i))))  ;; returns the insert point, x-value   )))   (setq i (+ i 1)) )  ;; we sort this last list, from left to right.  sorted_indexes contains the index (to be used in the "nth" and "ssname" function  ) (setq sorted_indexes (vl-sort-i x_values    (function (lambda (e1 e2) (< e1 e2))) )) ;; we set x_pointer to the x-value of the left panel (setq x_pointer (nth (nth 0 sorted_indexes) x_values)) ;; calculate the width of the panel  (setq width_panel (- (nth (nth 1 sorted_indexes) x_values) (nth (nth 0 sorted_indexes) x_values) ))  ;; we loop over sorted_indexes. (setq i 0) (repeat (length sorted_indexes)   (setq block (VLAX-ENAME->VLA-OBJECT (ssname blocks (nth i sorted_indexes))))   ;; set left and right point of the panel   (setq      lft (nth (nth i sorted_indexes) x_values)     rgt (+ lft width_panel)   )    ;; we look for the "SPACING" attribute   (foreach Attribute (vlax-invoke Block "GetAttributes")     (if (= (vla-get-TagString Attribute) "SPACING")       (progn         (setq spacing (atof (vla-get-TextString Attribute)))         ;;         (while (< x_pointer rgt)           (progn             (AT:InsertBlock "ballast" (list x_pointer y_value) 1.0 1.0 0.0)             (setq x_pointer (+ x_pointer spacing))           )         )         (princ "\n")       )     )   )      (setq i (+ i 1)) ));;; Insert block into drawing;;; #Name - name of block;;; #InsPt - insert point;;; #XScale - block X scale;;; #YScale - block Y scale;;; #Rot - block rotation;;; Alan J. Thompson, 04.21.09(defun AT:InsertBlock (#Name #InsPt #XScale #YScale #Rot) (if (or (tblsearch "block" #Name)         (findfile #Name)     ) ;_ or   (vla-insertblock     ((if (eq (getvar "cvport") 1)        vla-get-paperspace        vla-get-modelspace      ) ;_ if       (vla-get-ActiveDocument         (vlax-get-acad-object)       ) ;_ vla-get-ActiveDocument     )     (vlax-3d-point #InsPt)     #Name     #XScale     #YScale     #XScale     #Rot   ) ;_ vla-insert-block ) ;_ if) ;_ defun;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;(defun c:ballast ( / ) (ballast) (princ))
spacing.dwg
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:45:21 | 显示全部楼层
This is exactly what I was thinking of. Im glad it is possible. It works great in your test drawing which you have provided however in my drawings I am unable to make it work. Maybe i am using incorrect blocks, or attributes? I have attached a sample layout with blocks I would typically use.
 
test.dwg
回复

使用道具 举报

15

主题

315

帖子

361

银币

初来乍到

Rank: 1

铜币
25
发表于 2022-7-5 17:50:38 | 显示全部楼层
- My code requires a block called "ballast".  This is the block that will be inserted.
 
You can change this line, change "ballast" into your block name.
(AT:InsertBlock "ballast" (list x_pointer y_value) 1.0 1.0 0.0)
 
- The panel block (block name does not matter) requires an attribute with the tag: "SPACING"; the contents has to be the spacing value.
 
I don't have Autocad installed here, I will look at your file tomorrow.
回复

使用道具 举报

2

主题

15

帖子

13

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-5 17:51:28 | 显示全部楼层
I made a change to the block name in the routine and it worked just like it did in your test. That being said, there is still one issue. The panels have a row of ballast blocks in the rear and the front. Both of which have different spacings. Is there a way to have two sets of attributes per panel?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 04:06 , Processed in 0.414785 second(s), 74 queries .

© 2020-2025 乐筑天下

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