.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
remarkably similar to what I just did, but needs one more thing (maybe). If you want to maintain the AttributeReference Values of the original BlockReference, then you'll need to gather them up into a collection for when you insert the new BlockReference.

Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Thank's everyone who help me !!
Jeff's your answer works pefectly ! ty very much ! easy as hell !! ![]()
Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
that's truth chief, how i could do that chief ??
I was trying using that code but without success
For Each objId As ObjectId In btr
Dim obj As Object
obj = acTrans.GetObject(objId, OpenMode.ForWrite)
If TypeOf obj Is AttributeDefinition Then
Dim AttDef As AttributeDefinition = obj
Dim AttRef As New AttributeReference
AttRef.SetAttributeFromBlock(AttDef, bob.BlockTransform)
End If
Next
Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Since I don't really know how you plan on using this code, I'm guessing a little here, but I have an idea that would greatly simplify the process:
Do you intend to delete the originally selected block?
Do you intend to have the new block in the same location/orientation as the original block?

Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Do you intend to delete the originally selected block?
No, I only want to clone it, but without object references. solved.
Do you intend to have the new block in the same location/orientation as the original block?
I would like to have news blocks with the same orientation as the original but in a different selected point. solved.
My only problem now appears when i have clone it, if i create the blockreference by code i lose all attributes, but if i do it manually once i have clone it going to the insert option Autocad let me change all Attributes before insert it.
I would like to know what i have to do if i want to insert my attributes on my blockreference by code.
Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Essentially you have a unique situation where you can make the process much easier by cloning the original block reference to create your new reference.
Dim newBref As BlockReference
Using MS As BlockTableRecord = acTrans.GetObject(Br.OwnerId, OpenMode.ForWrite, False, True)
newBref = Br.Clone()
newBref.BlockTableRecord = newBtrId
MS.AppendEntity(newBref)
acTrans.AddNewlyCreatedDBObject(newBref, True)
End UsingThat way all the attributes are brought over with the clone, then move newBref to the new desired location, however it is you are doing that.

Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I am confused,
I first read through it quickly and the code I posted did not make much sense, but what I thought you were after and wanted.
Maybe I jumped in too quick and added to my confusion.
I apologize as Chief was getting trying to figure out your problem and my post might of side track it a bit.
The code I posted really just takes up space because it is just a copy of a existing 'BlockDefinition'.
From your first post, Chief's first reply would be the answer.
Just trying to help figure out what you after.
Maybe rewording question and replacing the word 'Block' with BlockReference or BlockDefinition might help?
Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
It's all good Jeff. While my first response is one approach that would have worked, the DeepClone idea made the code much simpler, and as I mentioned earlier in the thread, the Explode option has issues with non-uniformly scaled block references, which the DeepClone option handles just fine.
I personally struggle to see the value of this routine, but I choose not to dwell on the perceived usefulness, and just focus on the question instead. I figure he must have a purpose, even if that purpose is simply a learning experience.

Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I can't remeber off the top of my head but for some reason I was thinking that ExplodeToOwnerSpace worked with non-uniformly scaled block references.
I could be wrong.
Re: Copy paste with new block definition
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
In my code I have several blocks that are always scaled non-uniformly. I think there are reasons that I have not used ExplodeToOwnerSpace, but I will check some stuff out... I'll let you know




