.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Filter Block Selection By X,Y Coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hello,
I'm trying to select two specific types of blocks from a drawing so that I can create layouts for each one of the pairs of blocks in my drawing. Basically, one block is the outline of the piece of the drawing and the second contains information about the drawing. I would like to select all of the outline blocks and then create a selection to get the second block which is inside the bounds of the first block. I'm not sure how to create a set of typed values to do this. Here is my code so far which sets up a filter to get the first block and then for each of the blocks that it finds, it would select the block with all of the information which is where I am having problems. I don't know how to create a filter based upon location of the block. Is this possible and does someone have an example? Thanks for your help.
using (Transaction tr = acCurDb.TransactionManager.StartTransaction())
{
filList = new TypedValue[] {
new TypedValue((int)DxfCode.Operator,"<and"),
new TypedValue((int)DxfCode.Start,"INSERT"),
new TypedValue((int)DxfCode.BlockName,"D-1*"),
new TypedValue((int)DxfCode.Operator,"and>")};
// Build a filter list so that only block references are selected
filter = new SelectionFilter(filList);
//Select all
res = ed.SelectAll(filter);
// Do nothing if selection is unsuccessful
if (res.Status != PromptStatus.OK)
return;
//pull information from the selected objects
idArray = res.Value.GetObjectIds();
//Create the block reference array
blkRef = new BlockReference[idArray.Length];
//Loop through each selected object and store its block reference
for (int i = 0; i < idArray.Length; i++)
{
blkRef[i] = (BlockReference)tr.GetObject(idArray[i].ConvertToR edirectedId(), OpenMode.ForRead);
}
//LayoutManager lm = LayoutManager.Current;
for (int i = 0; i < blkRef.Length; i++)
{
filList = new TypedValue[] {
new TypedValue((int)DxfCode.Operator,"<and"),
new TypedValue((int)DxfCode.Start,"INSERT"),
new TypedValue((int)DxfCode.BlockName,"D-1*"),
//new TypedValue((int)DxfCode.XCoordinate),
//new TypedValue((int)DxfCode.Operator, ">="),
//new TypedValue((int)DxfCode.Real, blkRef[i].Bounds.Value.MinPoint.X),
//new TypedValue((int)DxfCode.XCoordinate),
//new TypedValue((int)DxfCode.Operator, "<="),
//new TypedValue((int)DxfCode.Real, blkRef[i].Bounds.Value.MaxPoint.X),
//new TypedValue((int)DxfCode.YCoordinate),
//new TypedValue((int)DxfCode.Operator, ">="),
//new TypedValue((int)DxfCode.Real, blkRef[i].Bounds.Value.MinPoint.Y),
//new TypedValue((int)DxfCode.YCoordinate),
//new TypedValue((int)DxfCode.Operator, "<="),
//new TypedValue((int)DxfCode.Real, blkRef[i].Bounds.Value.MaxPoint.Y),
new TypedValue((int)DxfCode.Operator,"and>")};
// Build a filter list so that only block references are selected
filter = new SelectionFilter(filList);
//Select all
res = ed.SelectAll(filter);
// Do nothing if selection is unsuccessful
if (res.Status != PromptStatus.OK)
return;
//pull information from the selected objects
idArray = res.Value.GetObjectIds();
//Create the block reference array
blkRefTB = new BlockReference[idArray.Length];
//Loop through each selected object and store its block reference
for (int j = 0; j < idArray.Length; j++)
{
blkRefTB[j] = (BlockReference)tr.GetObject(idArray[j].ConvertToR edirectedId(), OpenMode.ForRead);
}
}
tr.Commit();
}
Solved! Go to Solution.
Re: Filter Block Selection By X,Y Coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
From ObjectARX Doc:
- For point groups, the X, Y, and Z tests can be combined into a single string, with each separated by commas--for example, ">,>,*". If you omit an from the string (for example, "=,<>" leaves out the Z test), the "anything goes" "*" is assumed.
// [...]
new TypedValue((int)DxfCode.Operator,"<=,<=,*"),
new TypedValue((int)DxfCode.XCoordinate, MaxPoint,
new TypedValue((int)DxfCode.Operator,">=,>=,*"),
new TypedValue((int)DxfCode.XCoordinate, MinPoint),
// [...]
Re: Filter Block Selection By X,Y Coordinate s
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks, this is exactly what I was looking for as a solution. I just couldn't find something like this anywhere. I appreciate it.



