VBA Block 'merge'
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) 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? 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? 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 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.
页:
[1]