.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi All.
I have a weird problem with exploding block reference with vb.net as follows.
When I use BR.explode(DBObjectCollection), and append the entities in the object collection to model space,
the 3d Polylines inside the block reference do not get appended and I do not get any kind of error. The reason for this eludes me as of yet. (remember, simple polylines and lines and other objects do get appended to model space)
When I use BR.explodetoOwnerSpace(), the block reference explodes as it normally is expected to, but then I have no way to collect the objects from the exploded BR.
N.B, BR refers block reference.
Thanks for any help in advance.
I dont know whether any code is needed with this question but if it is, Ill attach it happily ![]()
Solved! Go to Solution.
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I've checked this code and it is work with 3DPolyline without problem:
[CommandMethod("ExplCurSpace")]
static public void ExplCurSpace()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Edit or;
Database db = Application.DocumentManager.MdiActiveDocument.Data base;
PromptEntityOptions opt =
new PromptEntityOptions("\nSelect a Block Reference: ");
opt.SetRejectMessage("Not a Block Reference");
opt.AddAllowedClass(typeof(BlockReference), true);
PromptEntityResult rs = ed.GetEntity(opt);
if (rs.Status == PromptStatus.OK) {
using (Transaction tr = db.TransactionManager.StartTransaction()) {
BlockTableRecord btrCur =
tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
if (btrCur == null) return;
BlockReference br =
tr.GetObject(rs.ObjectId, OpenMode.ForRead) as BlockReference;
if (br == null) return;
DBObjectCollection dbCol = new DBObjectCollection();
br.Explode(dbCol);
if (dbCol.Count > 0) {
foreach (DBObject dbObj in dbCol) {
Entity dbEnt = dbObj as Entity;
if (dbEnt != null) {
btrCur.AppendEntity(dbObj as Entity);
tr.AddNewlyCreatedDBObject(dbObj, true);
}
}
tr.Commit();
}
}
}
}
Try it.
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks Alexander For your quick reply.
The problem is, I have tried it. and it doesnt seem to work for me. I have also tried casting every DbObject to Entity3D and appending it. But the code just seems to skip over the polyline3d.
One thing, Could it be related to the scenario if i were calling this funciton from another class with a main function?
I do have implemented a workaround for the time being by using selection widnows but im not comfortable with them ![]()
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hassanhafeez33 wrote:
...The problem is, I have tried it. and it doesnt seem to work for me. I have also tried casting every DbObject to Entity3D and appending it. But the code just seems to skip over the polyline3d...
Entity3d is geometrical class - e.g. class which can not be database resident and has not DBObject as parent class . It is the same that casting apple to pear.
hassanhafeez33 wrote:
...One thing, Could it be related to the scenario if i were calling this funciton from another class with a main function?
Maybe.
hassanhafeez33 wrote:
...I do have implemented a workaround for the time being by using selection widnows but im not comfortable with them...
Sorry, but I do not understand this idea at all.
First of all try my code as separate command. If this code is not work as expected then:
1) Attach small dwg-file with block which has Polyline3d
2) In which AutoCAD version you tested this code?
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks again Alexander,
Ill try it tomorrow, its past sleeping time here so i gotta go. Ill surely update if things progress.
By sayin selection window, i mean that I did BR.explodetoOwnerSpace and then used ed.selectwindow to select the objects within the exisitin BR's extents.
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hassanhafeez33 wrote:
...By sayin selection window, i mean that I did BR.explodetoOwnerSpace and then used ed.selectwindow to select the objects within the exisitin BR's extents...
Sorry but It's like the worst solution:
1) Editor.SelectWindow operate only with visible on screen (current viewport) entities.
2) Editor.SelectWindow can select many other entities.
3) etc.
You can use ObjectAppended events in order to get ObjectId's of all entities added to Database with explodetoOwnerSpace method:
Getting the entities created from ExplodeToOwnerSpace API
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi again, Alexander.
Your solution regarding events works like a charm.
nice one. Im just curious, does it effect performance overall? I assume it would.
And realted to our original problem, I have worked out two reasons.
1. When a Block reference is scaled within a space, Your code and mine, do not seem to work with polylyine3ds. Whereas in an unscaled blockreference, your code and mine work perfectly.
2. When simple polylines are present in a block reference and it is scaled, the results seem strange. The polylines in the block reference seem to get exploded to lines directly. whereas polyline3ds do not appear at all. (Tried both with your code, and mine; which are essentially the same)
Could you check if you can reproduce this on your own?
Cheers. I know its a saturday but I dont have anything better to do
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
>> Im just curious, does it effect performance overall? I assume it would.
You can check it yourself but IMHO effect will be very small.
>>1. When a Block reference is scaled within a space, Your code and mine, do not seem to work with polylyine3ds.
>>Whereas in an unscaled blockreference, your code and mine work perfectly.
>>2. When simple polylines are present in a block reference and it is scaled, the results seem strange.
>>The polylines in the block reference seem to get exploded to lines directly. whereas polyline3ds do not appear at all.
>> (Tried both with >>your code, and mine; which are essentially the same)
If block has Polyline3d and scaled uniformly (e.g. Xscale == Yscale == Zscale) - block exploded as expected, but if it scaled nonuniformly than:
So with method Explode you can not explode nonuniformly scaled block with Polyline3d.
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thanks Again, Alexander.
But I wonder why its not implemented ![]()
Anyways. I really appreciate your help
keep up the good work!
Re: Problem with Polyline3D s in BlockRefer ence
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
hassanhafeez33 wrote:
But I wonder why its not implemented
![]()



