Jump to content
Developer Wiki and Function Reference Links Read more... ×
WhoCanDo

Finding objects within a perimeter

Recommended Posts

Hi,

 

I wish to add a Field Name value to a Wall item within the perimeter of a 2D polygon object.

 

At the moment, I have given the polygon a Name and then ..

ForEachObject (Record_Data, (Loc = 'Tmp') & ((T = Wall) or (T = RoundWall)));

 

However, some of the Wall items lie within the perimeter of a group of polygons.

 

The group, for example contains one large polygon and another smaller polygon within it's boundaries (representing a cutout).

 

Now, how do I do the same as above for a group?
 

Share this post


Link to post

Give them both separate names and use LOC Is Within Big Poly & LOC is Not Within Little Poly?

 

But I don't think that will get you an object the partially overlaps the small poly. You will probably have to manually compare the bounding boxes of the small poly to each object inside the large poly to check for overlap.

Share this post


Link to post
Posted (edited)

Thanks Pat,

 

No problem finding the bigger polygon, but (Loc = 'Tmp') does not seem to work on a group.

 

procedure Test_2;
var
x : integer;
h, hG : handle;
NetArea : real;
IsGroup : boolean;

procedure Count (hC : handle);
begin
x := x + 1;
end;

begin
h := FSActLayer;
IsGroup := False;

if (GetTypeN (h) = 11 { Group }) then
  begin
  SetDSelect (h);
  DelName ('Tmp');
  hG := FInGroup (h);
  NetArea := HArea (hG);
  DoMenuTextByName ('Copy', 0);
  hG := NextObj (hG);
  while (hG <> Nil) do
    begin
    if (NetArea < HArea (hG)) then
      begin
	  NetArea := HArea (hG);
      DoMenuTextByName ('Copy', 0);
	  end;
    hG := NextObj (hG);
    end;
  DoMenuTextByName ('Paste In Place', 0);
  h := LNewObj;
  IsGroup := True;
  end;
  
DelName ('Tmp');
SetName (h, 'Tmp');
ForEachObject (Count, (Loc = 'Tmp') & ((T = Wall) or (T = RoundWall)));

message (x);
end;
run (Test_2);

image.thumb.png.bc04d030eb31f01c149c90361d75826e.png

Edited by WhoCanDo
Add Image

Share this post


Link to post

LOC only works for 2D objects (polys, rects, ovals, etc.) and spaces as far as I know.  It does not work for Groups or 3D objects (other than spaces) or other PIOs (there are probably some exceptions, but I don't know them.)

 

But it does work even when the objects are INSIDE of groups.  So you can't set the Group to be TMP, but you can enter the group, name the big poly and then exit the group and LOC will still work.

 

Does that help?

 

  • Like 1

Share this post


Link to post

Got it Pat,

 

I think I was heading toward Naming something other than the group but your suggestion of Naming something within a group worked perfectly.

 

Thanks 😃

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×