rosebud5 Posted September 25, 2018 Share Posted September 25, 2018 Hi there, I am wishing that there was a script to take 2d polygons that are open and make them closed within a certain tolerance. I import DWG's a lot and I always have to spend a good deal of time finding tiny little breaks and inconsistencies in order to fill the objects. Is there any kind of script that would do an auto join if the polyine is a short distance away? Thanks, Quote Link to comment
MullinRJ Posted September 26, 2018 Share Posted September 26, 2018 rosebud5, Here's a no-frills script to CLOSE all Polygons and Polylines on the Active Layer. This script does not discern if the opening is "a short distance away". It will close ALL Polys. If you need that capability, will you please define how "close" is "close enough to close", or how "open" is "too far to close". PROCEDURE ClosePolys; { Close all Polygons and Polylines on Active Layer. } { This script: } { - will enter Groups on the Active Layer; } { - will NOT "show" segments that are "hidden" in the middle of a Polyline; } { - does not require objects to be selected, nor will it change the selection state; } { - will NOT work on a collection of LINES that "looks" like a Poly. } { 26 Sep 2018 - Raymond J Mullin } { DISCLAIMER: THIS SCRIPT IS OFFERED AS IS. SAVE YOUR FILE BEFORE USING THIS SCRIPT. } { UNDO WILL WORK, BUT ALWAYS BE SAFE. } function CloseIt(H :Handle) :Boolean; { Closes Polygons and Polylines. Does not affect Polys that are already CLOSED. } Var OT :Integer; Begin OT := GetTypeN(H); { object type } if (OT=5) | (OT=21) then { Polygon or Polyline } SetPolyClosed(H, TRUE); { close the Poly } End; { CloseIt } BEGIN ForEachObjectInLayer(CloseIt, 0, 1, 0); { All objects, Enter Groups, Active Layer } SysBeep; END; Run(ClosePolys); Raymond Quote Link to comment
rosebud5 Posted September 26, 2018 Author Share Posted September 26, 2018 Hi Raymond, thanks so much for the speedy reply, I am attaching the file example. A lot of times I will import a dwg from kholer or some other site and need to fill it and have to spend a lot of time finding the tiny spaces between lines. Some of the shapes I can fill with the paint bucket but others won't fill and I waste a lot of time trying to close everything. I am including a sample file where the two side shapes are not filling. Maybe I should have said close all lines into a poly. Thanks, close lines sample.vwx Quote Link to comment
MullinRJ Posted September 26, 2018 Share Posted September 26, 2018 Hi rosebud5, I opened your file and I see your problem. The artwork you are importing was not drawn to be filled. It is line art and close is definitely good enough for the person who created it. You obviously want it to perform better than it was designed. Okay, I can appreciate that. When you say you are "wasting a lot of time closing the gaps", are you using the Connect/Combine Tool and/or the Join Tool to remove the gaps, or are you adjusting the Polys, Lines, and Arcs manually? If you are doing the latter, you can save a lot of time by using the right built-in tools. If you're already using those tools, then perhaps a custom script is in order. Though I haven't written one, perhaps one of the other scripters on this forum already has. I'd wait a little longer to see if someone else responds with a suitable answer. If nobody responds, you might want to pursue having a custom script written for you. Depending on how often you need to perform cleanup on these imported drawings, it might well be worth the investment. It won't be a simple script, so it won't be overly cheap; but if it saves you 10-50 hours (or more) a year it should be reasonably affordable. For now, All the best, Raymond Quote Link to comment
JBenghiat Posted October 1, 2018 Share Posted October 1, 2018 In this sample file, you're looking to close a gap between an endpoint and a line, which is much harder than closing up end points that are close but not overlapping. This is particularly complicated if you want to connect arcs and beziers, as you would have to extrapolate the path of every open line, check if it intersects every other line or segment, find the closest intersection, and extend. Using a combination of Select Connected Objects, Compose, Combine/Connect, and the inner/outer boundary modes of the polygon tool can make fairly quick work of this. Quote Link to comment
rosebud5 Posted October 1, 2018 Author Share Posted October 1, 2018 Thanks for the reply, I guess that I am looking for something like the smart paint tool that is in illustrator 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.