Wopke Posted April 4, 2023 Share Posted April 4, 2023 I'm an enthusiastic VW user for over a decade. Recently I noticed I have to do many things often and as such I'm starting to look at automation of tasks. I'm considering to learn Python as I would like to automate several things, but it will take time. I like to draw shadow on facades to make the more vibrant. At the moment I'm willing to pay an experienced user some money for a small script related to the shadow. What I basically need is; Take on or more squares; Take the top line and offset 50mm down; Take the right line and offset 50mm to the left; Create new rectangles from that set of lines; "Add surface" those two new rectangles; Fill color black, oppacity 40%. Is there someone in this forum willing to write this for me or can you point me to a place where I can find someone? Willing to pay. I guess I'm looking for the code in Python. Quote Link to comment
Letti R Posted April 5, 2023 Share Posted April 5, 2023 Hello, assuming all the rectangles are alligned to the x and y axis the following script should do the trick. # FUNCTIONS def selection_on_active_layer_to_handle(): handles = [] def callback_selection_on_active_layer_to_handle(handle): handles.append(handle) vs.ForEachObject(callback_selection_on_active_layer_to_handle, "(NOTINDLVP & NOTINREFDLVP & ((L='" + vs.GetLName(vs.ActLayer()) + "') & (VSEL=TRUE)))") return(handles) # SCRIPT selection = selection_on_active_layer_to_handle() for item in selection: if vs.GetTypeN(item) == 3: blank = vs.CreateDuplicateObject(item, vs.Handle(0)) tool = vs.CreateDuplicateObject(item, vs.Handle(0)) vs.HMove(tool, -0.5, -0.5) # change "-0.5, -0.5" to the desired offset, depending on the units you use in your drawings vs.SetFPat(blank, 1) vs.SetFillBack(blank, (0, 0, 0)) vs.SetOpacityN(blank, 40, 40) vs.ClipSurfaceN(blank, tool) vs.DelObject(blank) vs.DelObject(tool) vs.SetDSelect(item) You will have to change some values in the script because i dont know which units you use. I kept this script as simple as possible so i dont take care of different document units via the script. I think you maybe want to modify the script even further, because from your post it was unclear: - If the original rectangles should be deleted by the script - If the Shadow has an outline - If so, which opacity - etc. Here is how this script works: - Read in all the selected objects on the active layer and "save" them in a list - Go through all the objects in this list - If the object is a rectangle - Create two duplicates of the rectangle - Move one of them by the amount you specified the offset to be (width and height of the shadow) - Set the color and opacity of the other duplicated rectangle to the right values (black and 40%) - Clip the moved rectangle from the colored rectangle - Deselect the original item Regards, Letti 4 Quote Link to comment
Wopke Posted April 5, 2023 Author Share Posted April 5, 2023 This works perfectly. Thank you very much. You made my life a lot easier. All the karma to you. Quote Link to comment
JBenghiat Posted April 7, 2023 Share Posted April 7, 2023 While I fully support exploring scripting solutions, it's worth noting you can do this with Drop Shadows in attributes. The offset is in page units. You can set these to be class defaults, and just assign the class to all the objects that you want to have the shadow. Quote Link to comment
Letti R Posted April 8, 2023 Share Posted April 8, 2023 Hello, i thought @Wopke wanted the "inner" shadow of a rectangle. Is this also possible with the drop shadow settings? Regards, Letti Quote Link to comment
JBenghiat Posted April 8, 2023 Share Posted April 8, 2023 Ah yes, I misread the directions of the offsets. The drop shadow attribute would only work if the façade were a single polygon with holes. For example, use the inner boundary mode of the polygon tool to create the shape, then apply the drop shadow. So possible, but a bit cumbersome. 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.