• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    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
    Please use plain text.
    Active Member
    PaulPotts
    Posts: 7
    Registered: ‎09-08-2011

    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:

    Please use plain text.
    Active Member
    PaulPotts
    Posts: 7
    Registered: ‎09-08-2011

    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

     

     

    Please use plain text.
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    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
    Please use plain text.
    Active Member
    PaulPotts
    Posts: 7
    Registered: ‎09-08-2011

    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. 

    Please use plain text.
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    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
    Please use plain text.
    Mentor
    Posts: 241
    Registered: ‎05-12-2009

    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
    Please use plain text.
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    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
    Please use plain text.
    Mentor
    Posts: 241
    Registered: ‎05-12-2009

    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
    Please use plain text.
    *Expert Elite*
    chiefbraincloud
    Posts: 736
    Registered: ‎02-13-2008

    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
    Please use plain text.