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

    .NET

    Reply
    Active Contributor
    Posts: 30
    Registered: ‎03-22-2010
    Accepted Solution

    Copy object inside same drawing... problems

    560 Views, 4 Replies
    01-27-2011 09:04 AM

    I've been using this method for "copying" objects from one point to another..

     

    Dim EntityCopy As Entity = EntitySource.GetTransformedCopy(Matrix3d.Displacement(startPT.GetVectorTo(EndPT)))

     

    But have run into a few glitches, not program stopping glitches just annoying ones..

     

    With polylines, not all the properties are copied, one for example is the "global width".  it gets re-set to 0.

     

    Problem is with dynamic blocks..  the above method creates a "dumb" version of the block rather than a functional dynamic version of the block..

     

    Can anyone show me a way to fix this, or an alternate method for copying objects from point a to point b?

    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,334
    Registered: ‎10-08-2008

    Re: Copy object inside same drawing... problems

    01-27-2011 02:57 PM in reply to: C_Witt

    In that case as for  Tony Tanzillo's recomendation I wouldt use

    DeepCloneObjects method of DataBase instead

    Try this quicky

    No error trapping in there, do it by yourself

        <CommandMethod("como")> _
        Public Shared Sub CopyMove()
            Dim doc As Document = acApp.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
    
            Dim peo As New PromptEntityOptions(vbLf & "Select object:")
    
            Dim per As PromptEntityResult = ed.GetEntity(peo)
    
            If per.Status <> PromptStatus.OK Then
    
                Return
            End If
            Dim startPT As Point3d = ed.GetPoint(vbCr & "Pick a point from: ").Value
            Dim EndPT As Point3d = ed.GetPoint(vbCr & "Pick a point to: ").Value
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
    
                Dim sourceId As ObjectId = per.ObjectId
    
                Dim EntitySource As Entity = CType(tr.GetObject(sourceId, OpenMode.ForRead), Entity)
                Dim ids As New ObjectIdCollection()
                ids.Add(sourceId)
                db.DeepCloneObjects(ids, db.CurrentSpaceId, New IdMapping, False)
                Dim EntityCopy As Entity = CType(tr.GetObject(ids(0), OpenMode.ForRead), Entity)
                EntityCopy.UpgradeOpen()
                EntityCopy.TransformBy(Matrix3d.Displacement(startPT.GetVectorTo(EndPT)))
                EntityCopy.ColorIndex = 2
    
                tr.Commit()
            End Using

     

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    Active Contributor
    Posts: 30
    Registered: ‎03-22-2010

    Re: Copy object inside same drawing... problems

    01-28-2011 06:13 AM in reply to: C_Witt

    Thank you, that is perfect. :smileyhappy:

    Please use plain text.
    *Expert Elite*
    Hallex
    Posts: 1,334
    Registered: ‎10-08-2008

    Re: Copy object inside same drawing... problems

    01-28-2011 06:52 AM in reply to: C_Witt

    You're welcome :smileyhappy:

    Glad to help

    Regards,

     

    Oleg

     

    ~'J'~

    _____________________________________
    C6309D9E0751D165D0934D0621DFF27919
    Please use plain text.
    Valued Contributor
    iwcwoodworker
    Posts: 59
    Registered: ‎03-31-2003

    Re: Copy object inside same drawing... problems

    01-28-2011 07:50 AM in reply to: Hallex

    Working with making blocks from existing entities in a file. I've run into problems with iterating through the entities within a selection set and writing them to my new blocktablerecord. How do I take those items from my selection set and add them to this new block? All thoughts and help are appreciated. 

    Please use plain text.