.NET

Reply
*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 11 of 22 (535 Views)

Re: Copy paste with new block definition

09-09-2011 12:47 PM in reply to: jeff

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.

Dave O.                                                                  Sig-Logos32.png
Active Member
PaulPotts
Posts: 7
Registered: ‎09-08-2011
Message 12 of 22 (487 Views)

Re: Copy paste with new block definition

09-12-2011 02:40 AM in reply to: jeff

Thank's everyone who help me !! 

 

 :smileysurprised: Jeff's your answer works pefectly ! ty very much !  easy as hell !! :smileyvery-happy:

Active Member
PaulPotts
Posts: 7
Registered: ‎09-08-2011
Message 13 of 22 (474 Views)

Re: Copy paste with new block definition

09-12-2011 03:43 AM in reply to: chiefbraincloud

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

 

 

*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 14 of 22 (455 Views)

Re: Copy paste with new block definition

09-12-2011 11:20 AM in reply to: PaulPotts

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?

 

 

Dave O.                                                                  Sig-Logos32.png
Active Member
PaulPotts
Posts: 7
Registered: ‎09-08-2011
Message 15 of 22 (441 Views)

Re: Copy paste with new block definition

09-12-2011 11:09 PM in reply to: chiefbraincloud

 

 

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. 

*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 16 of 22 (427 Views)

Re: Copy paste with new block definition

09-13-2011 12:01 PM in reply to: PaulPotts

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 Using

 That 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.

Dave O.                                                                  Sig-Logos32.png
Valued Mentor
jeff
Posts: 321
Registered: ‎05-12-2009
Message 17 of 22 (410 Views)

Re: Copy paste with new block definition

09-13-2011 04:02 PM in reply to: PaulPotts

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?

 

 

 

 

You can also find your answers @ TheSwamp
*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 18 of 22 (406 Views)

Re: Copy paste with new block definition

09-13-2011 04:14 PM in reply to: jeff

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.

 

 

Dave O.                                                                  Sig-Logos32.png
Valued Mentor
jeff
Posts: 321
Registered: ‎05-12-2009
Message 19 of 22 (402 Views)

Re: Copy paste with new block definition

09-13-2011 04:28 PM in reply to: chiefbraincloud

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.

You can also find your answers @ TheSwamp
*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 20 of 22 (392 Views)

Re: Copy paste with new block definition

09-13-2011 09:11 PM in reply to: jeff

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

Dave O.                                                                  Sig-Logos32.png

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community