乐筑天下

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

[编程交流] VBA Block 'merge'

[复制链接]

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 16:56:37 | 显示全部楼层 |阅读模式
So I have this project where I wantto write a vba script to draw 'something' dynamicly. Its something basic, a table with chairs, having the chairs/table legs relative to each other and dependant on user input trough a form.
 
I have 3 blocks, the table legs, the chairs and the tabletop. I'd like to keep them as 3 seperate blocks but I want another 'block' or blockreference so when the user moves the tabletop, the table legs move as well.
 
I think I will need to do a sset.Select acadSelectionSetAll but I'm not quite sure what to do with it.
 
So in short what is fixed is me having 3 blocks, I can make wathever blockreferences as needed.
 
Shout if you need some code to get a better view on my project, its pretty basic though. (wanted to get used to VBA a bit, first time I work in it)
回复

使用道具 举报

0

主题

132

帖子

198

银币

限制会员

铜币
-21
发表于 2022-7-6 17:13:57 | 显示全部楼层
Let me see if I get what you want. You want to take three blocks or whatever selection set you grab and then create a new block reference from those. Is that what I am reading?
回复

使用道具 举报

1

主题

2

帖子

1

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 17:35:29 | 显示全部楼层
I want to grab 2 out of the 3 I have.
 
See, I have 3 subs where I create my blocks, and then in my 'main' function I place them in my ModelSpace.
 
The placement of the tabletop is obvious, the table legs is with a few loops, ditto for the seats.
 
Currently I just did a bunch of "Set tafelblockreference = ThisDrawing.ModelSpace.InsertBlock(insertionpnt, "stoelblock", 1#, 1#, 1#, rotatiestoelen)" but I'm guessing/hoping there is a better way to do it so I can get my tabletop+table legs as a merged reference.
 
Either by changing the way I "set" them in my main or by selecting them, turning them into a new block, deleting the old reference and creating a reference for the new (merged) block?
回复

使用道具 举报

0

主题

252

帖子

290

银币

限制会员

铜币
-8
发表于 2022-7-6 17:45:43 | 显示全部楼层
What I do is create a "Table" block, then insert the tabletop and legs into that definition.  When your done, you have 1 block made up of other blocks
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-6 17:57:07 | 显示全部楼层
Ok a way maybe out, if you have a master block "Kitchen table" give it a unique attribute ID say table 1 2 3 4 etc in your chairs save the master blocks ID as an attribute "Table5" into the chair block, so you always know which blocks go with which table.
 
Chair1 table5
Chair2 table5
Chair3 table6 etc
 
Now move a Kitchen table now it gets sneaky, you have saved the relative angle and distance from the table to the chair block insertion point.
 
Chair table5 30 1.345
 
Write an update program searches the chairs individually moves them relative to their new position based on the insertion point of the correct table block. You need two datasets chairs and tables.
 
If you need to move a chair rewrite the relative angle & distance back into the chair block you can not just do a move! Else next update goes back to where it was.
 
Bit of homework I am sure all the code is here to write a block, search for blocks, move blocks etc You need 3-4 programs but they could all start from the 1 option "insert a Kitchen Table" You can definately pick a block and then write its attributes into another block. Probably do one step at a time create subs that can be used in multipe steps rather than multiple programs.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-4 19:18 , Processed in 0.781306 second(s), 62 queries .

© 2020-2025 乐筑天下

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