Is there any SKILL codes which able to get the outer points of selected objects?
I was trying to create a new function which may required to get the outer points of selected objects (polygon/rectangle/instances and etc). I want to get a list of points where i can use it to create a polygon which cover all selected objects.
Example, let say i have selected 10 polygons, and i want a function to return me a list of outer points of my selected object. Can someone help?
You can do a union of all the selected objects bboxes. trBBoxUnion( geGetSelSet()~>bBox )
procedure( trBBoxUnion( bBoxList )let( ( llxList llyListurxList uryListminllx minllymaxurx maxury)llxList = foreach( mapcar bBox bBoxListxCoord( lowerLeft( bBox )))llyList = foreach( mapcar bBox bBoxListyCoord( lowerLeft( bBox )))urxList = foreach( mapcar bBox bBoxListxCoord( upperRight( bBox )))uryList = foreach( mapcar bBox bBoxListyCoord( upperRight( bBox )))minllx = apply( 'min llxList )minlly = apply( 'min llyList )maxurx = apply( 'max urxList )maxury = apply( 'max uryList )list( minllx:minlly maxurx:maxury )) ; let) ; proceduretrBBoxUnion( list( list(0:0 100:100) list(50:50 150:150)))
I presume that you are asking for the actual points of the resultant combined shape, rather than the overall bounding box? I think that the easiest way to get this would be to use something like dbLayerAnd on the input shapes to create a temporary shape, get the points from this shape and then delete it when you're done with it. It may be a little clunky, but it would be simpler than other methods that I can think of.
Hope this helps,
In reply to babji:
Thanks for your propose solution but this function only able to get the bounding box( bBox) of the selected objects. Thanks a lot.
I was looking for a function which able to get the outer shape (polygon) for a selected object. It works similar like mark net, when you mark a net, it will highlight only the outer shape of the net, looks like big highlighted polygon. My intention to get the this big highlighted polygon's points and proceed for next step.
In reply to skillUser:
Thanks for your propose solution. I did try several approach including dbLayerAnd but it doesn't work when selected shapes is not overlapping each other. As a result, this function only creates individual shapes.
Any idea? I can't figure out any way in getting this done. Hoping there are ideas from anyone in this forum. Thanks a bunch.
In reply to kbhow:
In reply to StefanSL:
Sorry that i can't really get what you means. Any where thanks.
I was trying to get outer shape of selected objects as below.
___ _ _ _
|_ _| | |
____ ___ ___ | |___
___| | | |____ _ __| |____
|__ ___ | |_______| => |______________________|
Hoping this help to make my question clear. Thanks
the "convex hull" would look like this:
___ _ _ _ |_ _| / \
____ ___ / \
___| | | |____ / \
|__ ___ | |_______| => |_ ________ |
just the outer points are connected in a way that all points are inside the newpolygon; an interesting geometrical problem, there are some algorithms available.
Possibly you could achieve a result similar to your drawing by upsizing all shapesto an intermediate layer by an amount that's sufficient to close all gaps, the shapes will merge,then downsizing by the same amount, the outlines should look like your drawing butthe gaps will stay closed.
Size resp. leHiSize() will not merge the shapes,dbLayerSize() or "Tools - Layer generation ... GROW" should do the job.
A good place to start would be with http://en.wikipedia.org/wiki/Convex_hull and http://en.wikipedia.org/wiki/Convex_hull_algorithms
That said, I'm not sure it's quite a convex hull you want, because I suspect you want it to follow the outer edges rather than being like an elastic band around all the outermost points.
In reply to Andrew Beckett:
Thanks for the sharing.
Ya, you're right.I actually want the outer edge rather than convex. Do you have any idea? At the same time, i'll go through the link the you share, hoping can get some hint or inspiration from that.
besides of the convex hull approach, my second proposal was to apply aupsizing-/downsizing-cycle to your shapes, did you already try if this fulfills your needs?
si=geGetSelectedSet()cvid = geGetEditCellView()stmp=dbLayerSize(cvid "TMPLAYER" si 3.5)so=dbLayerSize(cvid "TGTLAYER" stmp -3.5)
applying a suitable sizing instead of 3.5um will merge yourshapes, even from more than one layer, into one shape;downsizing this shape by the same amount will result ina shape that should do what you want...
Cool. This way never get into my mind, but i believe this will solve my problem. I'll play around with this approach.
Thanks a lot.
if one of the initial shapes is located far off, you may run into a problem,using the same value for upsizing and downsizing can result inmore than one shape, cause the downsize step could remove the interconnectagain. You should check the result of your operation ifit's really just one shape.
To be slightly pedantic, even if it is effectively one shape, it's possible that the dbLayer functions may return more than one shape if there are too many points.
There's an optional argument to dbLayer* functions which specifies the maximum number of vertices - and the default is (I think, if my memory is correct) 200. Beyond that it automatically splits into pieces. This was done because some formats historically have limits on the number of vertices (e.g. stream format had a historical limit of 200 points per polygon).
So counting the number of shapes produced may not be sufficient to detect gaps if there are lots of vertices in the resulting shape (if it has an outline like the coast of Norway ;-> ). That said, I believe that the upper limit is enormous (not even sure there is an upper limit) in OA versions is very high; in CDB the upper limit of number of vertices per polygon is 4000 (I think). So you may be able to use Stefan's approach still if you have a relatively small set of data to find the "hull" for.