michaelk Posted June 19, 2017 Share Posted June 19, 2017 Is it possible to duplicate a symbol (or a door. or a window) inserted into a wall without duplicating the wall also? If I wasn't scripting it I would copy the symbol/door/window and then paste in place to get the symbol/door/window copied in the same location (or any location - I could always move it later I guess) Thanks! Quote Link to comment
Pat Stanford Posted June 19, 2017 Share Posted June 19, 2017 So why not do the copy paste in the script. It seems to work. If you want the new object to be In Wall, just use a SetParent. DoMenuTextByName('Copy',0); DoMenuTextByName('Paste in Place',0); Just so you don't feel too bad, I just spent 45 minutes coming to this realization. ;-) Quote Link to comment
michaelk Posted June 19, 2017 Author Share Posted June 19, 2017 … because I thought there MUST be another (better) way to do it! Quote Link to comment
Pat Stanford Posted June 19, 2017 Share Posted June 19, 2017 There probably is and @MullinRJwill probably point it out to both of us shortly. ;-) Quote Link to comment
bcd Posted June 19, 2017 Share Posted June 19, 2017 Turn off the wall insertion mode of the Selection tool & Alt drag 1 Quote Link to comment
MullinRJ Posted June 20, 2017 Share Posted June 20, 2017 Hi Pat, Don't make me laugh (too late). When I read Michael's second post this morning, I thought, "better" way?!? What's wrong with Copy / Paste? I've been using it since 1990 and it's never let me down. And before you threw my name onto the Coliseum Floor, I thought maybe hDuplicate() would work, so I tried it on a single window in a wall. It seemed simpler, but it wasn't working. Nope, this wasn't better, and real work got in the way, so I shelved it. After reading your second post (and laughing) I recreated the file and tried it again. The duplicate and the original windows seem to lock themselves to each other when hDuplicate() is used. I can't drag the duplicate window around after I create it. The new window doesn't cut the wall properly in Plan, though the OIP says it is a "Window In Wall". Lastly, I can't delete it. Select it, yes; delete it, no. If I delete the original window, then both delete – very odd. They seem joined at the hip. Perhaps this is a bug. I don't know if hDuplicate should work on Windows in Walls. Naively, I think it should. I'll send it in and see what comes back. So, after spending more than an hour pushing dead code around, I tried your approach — Copy / Paste (in Place). It works like a champ. The two windows act as separate entities, interactively and programatically. I'm giving your approach 2-thumbs-up. Michael, do what Pat says. He's usually right*. ;-) Raymond * When he's finished his morning coffee, he flies back from Columbia (Maryland). He never has to launder his bed linens, he just creates new spreadsheets. When asked to solve vector problems, he is never wrong, and his answers always follow the Right–Hand–Rule. He IS the Most Interesting Man On The Forum! 1 Quote Link to comment
michaelk Posted June 20, 2017 Author Share Posted June 20, 2017 15 minutes ago, MullinRJ said: Michael, do what Pat says. He's usually right*. ;-) Hey Raymond I always do! Quote Link to comment
Pat Stanford Posted June 20, 2017 Share Posted June 20, 2017 I don't always Vectorscript, but when I don't that Python white space makes me cranky. Code Responsibly my Friend. 1 Quote Link to comment
bcd Posted June 20, 2017 Share Posted June 20, 2017 19 hours ago, bcd said: Turn off the wall insertion mode of the Selection tool & Alt drag Aha - didn't notice this was in the Vectorsript forum. my bad. Quote Link to comment
Pat Stanford Posted June 20, 2017 Share Posted June 20, 2017 @bcd Nothing to be sorry about. You actually hit on the answer. With the Wall Insertion Mode off, the Duplicate works as Michael, Raymond and I wanted it to. DOH! Great solution. Procedure Test; Var H1, H2: Handle; B1: Boolean; Begin B1:=GetPref(581); SetPref(581, False); H1:=FSActLayer; H2:=CreateDuplicateObject(H1, ActLayer); HMove(H2,60",60"); SetPref(581,B1); End; Run(Test); Quote Link to comment
michaelk Posted June 20, 2017 Author Share Posted June 20, 2017 That's why this forum is so fun. Thanks Brian, Pat, & Raymond! Quote Link to comment
bcd Posted June 20, 2017 Share Posted June 20, 2017 yeah - blindfold on & ran through the door Quote Link to comment
Pat Stanford Posted June 20, 2017 Share Posted June 20, 2017 That's why I try to read everything on the board. You never know when an idea from somewhere totally different will make a huge difference to what you are doing. Quote Link to comment
michaelk Posted June 23, 2017 Author Share Posted June 23, 2017 OK. More questions. Pat. That script isn't working for me. Just tried it in a blank file. Created a wall. Stuck a window in it. Selected the window and ran the script. It duplicated the wall with the window in it. Problem 2. Your idea of using DoTextByName does work if I select a window in a wall. But a ForEachObject with the criteria being Type is window won't select the window. It doesn't seem to select anything. Any more ideas? Quote Link to comment
Pat Stanford Posted June 26, 2017 Share Posted June 26, 2017 I don't know what happened. It worked when I wrote and tested it. When I downloaded it after you said it didn't work I couldn't get it to work either. I will try later to see if I can figure out what is different. Quote Link to comment
michaelk Posted June 26, 2017 Author Share Posted June 26, 2017 …a rip in the space/time/vectorscript continuum? Quote Link to comment
twk Posted June 26, 2017 Share Posted June 26, 2017 Just chiming in, I started with Vectorscript but have moved on to Python, as it's much easier -for me- to learn and use. Hopefully this is ok here, I guess you could convert it to VS if needed. Below is a script in python: import vs # copy symbol/plugin out of wall # As Pat said earlier, spaces/tabs are important in python # I always use an external editor to check for this before pasting my code back into vectorworks # I use PyCharm Community Edition def list_objs_inserted(h_wall): h_obj = vs.FIn3D(h_wall) list_objsinserted = [] while h_obj != None: if vs.GetTypeN(h_obj) in [86, 15]: list_objsinserted.append(h_obj) h_obj = vs.NextObj(h_obj) return list_objsinserted # A Wall needs to be selected! h2_wall = vs.FSActLayer() vs.SetDSelect(h2_wall) objs_in_wall = list_objs_inserted(h2_wall) for obj in objs_in_wall: newObj = vs.CreateDuplicateObject(obj, None) # None passed in as last parameter just places a copy on the layer you're on vs.SetSelect(newObj) Got the idea from @orso b. schmid's website here : http://www.vectorlab.info/index.php?title=Han-First_Selected_in_Active_Container That website is an invaluable resource for vectorworks vs/python coders HTH Tui Quote Link to comment
Pat Stanford Posted June 27, 2017 Share Posted June 27, 2017 DING DING DING!!! We Have A Winner!!! Thanks, Tui! Put door in a wall and select the door and run the following script Message(GetTypeN(FSActLayer)); For me it returns object type 68 = Wall. That expands why the CreateDuplicateObject is duplicating the complete wall. So now we just need to use Tui (and C's) Fin3D Trick to get the objects. The following works to duplicate every PIO in a wall. It is left to the reader to figure out how to filter out the objects that should not be duplicated. Procedure Test; Var H1,H2,H3: Handle; Begin H1:=FSActLayer; SetDSelect(H1); H2:=FIn3D(H1); While H2 <> Nil do Begin If GetTypeN(H2)=86 then H3:=CreateDuplicateObject(H2,Nil); HMove(H3, 60",60"); H2:=NextObj(H2); End; End; Run(Test); Quote Link to comment
michaelk Posted June 27, 2017 Author Share Posted June 27, 2017 Thanks Tui & Pat! I had been reading about parent objects. This makes it really much more clear! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.