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].ConvertToRedirectedId(), 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].ConvertToRedirectedId(), OpenMode.ForRead); } } tr.Commit(); }
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
From ObjectARX Doc:
// [...]
new TypedValue((int)DxfCode.Operator,"<=,<=,*"),
new TypedValue((int)DxfCode.XCoordinate, MaxPoint,
new TypedValue((int)DxfCode.Operator,">=,>=,*"),
new TypedValue((int)DxfCode.XCoordinate, MinPoint),
// [...]
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Thanks, this is exactly what I was looking for as a solution. I just couldn't find something like this anywhere. I appreciate it.
This is very intersting. I learned something new here.
Would anyone know what exactly the below code is doing?
new TypedValue((int)DxfCode.Operator,"<=,<=,*"),
new TypedValue((int)DxfCode.XCoordinate, MaxPoint,
new TypedValue((int)DxfCode.Operator,">=,>=,*"),
new TypedValue((int)DxfCode.XCoordinate, MinPoint),
// [...]
My guess is as follows: it basically is used to help create a selection filter such that:
Am i interpreting the above correctly?
chrs for your help.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Can't find what you're looking for? Ask the community or share your knowledge.