CopyObject and ObjectDBX

Discussion in 'AutoCAD' started by SpeedCAD, Feb 13, 2004.

  1. SpeedCAD

    SpeedCAD Guest

    Hi...

    Some example of CopyObject with ObjectDBX??. Thanks
     
    SpeedCAD, Feb 13, 2004
    #1
  2. SpeedCAD

    Jeff Mishler Guest

    Here's a sub from a routine that copies multiple objects from a set
    window crossing area in the current drawing and creates any number of
    new drawings with those objects. I have not commented it at all, but it
    should give you an idea of how to handle it.

    HTH,
    Jeff

    Public Sub dwgsplit(dblMin, numX, numY)
    Dim dwgSS As AcadSelectionSet
    Dim y As Long
    Dim x As Long
    Dim llp(0 To 2) As Double
    Dim urp(0 To 2) As Double
    Dim dwgPath As String
    Dim dwgName As String
    Dim dwgPre As String
    Dim dwgPost As String
    Dim newdwg As AcadDocument
    Dim docs As AcadDocuments
    Dim dwgOrig As String

    dwgOrig = doc.Name
    Set docs = doc.Application.Documents
    dwgPath = doc.Path
    dwgPre = GridData.PrefixBox.Value
    dwgPost = GridData.SuffixBox.Value
    For y = 0 To numY - 2
    For x = 0 To numX - 2
    On Error Resume Next
    doc.SelectionSets.Item("split").Delete
    Set dwgSS = doc.SelectionSets.Add("split")

    llp(0) = dblMin(0) + (GridX * x)
    llp(1) = dblMin(1) + (GridY * y)
    urp(0) = llp(0) + GridX
    urp(1) = llp(1) + GridY
    doc.Application.ZoomWindow llp, urp
    dwgSS.Select acSelectionSetCrossing, llp, urp
    On Error GoTo 0
    If dwgSS.Count > 4 Then
    ReDim exportSS(0 To dwgSS.Count - 1) As Object
    Dim I As Long
    For I = 0 To dwgSS.Count - 1
    Set exportSS(I) = dwgSS.Item(I)
    Next I
    dwgCount = dwgCount + 1
    dwgName = dwgPath & "\" & dwgPre & Format(dwgCount,
    "00") _
    & dwgPost & ".dwg"
    Set newdwg = docs.Add
    docs.Item(dwgOrig).CopyObjects exportSS,
    newdwg.ModelSpace
    newdwg.SaveAs (dwgName)
    newdwg.Close
    End If
    Next x
    Next y
    doc.Application.ZoomExtents
    End Sub
     
    Jeff Mishler, Feb 13, 2004
    #2
  3. SpeedCAD

    SpeedCAD Guest

    Hi...

    Thank you, I will save it. But I have a question. This it can make with ObjecDBX?
     
    SpeedCAD, Feb 15, 2004
    #3
  4. SpeedCAD

    Mark Propst Guest

    ObjecDBX?

    yes, essentially the same code except here...
    <snip> Set newdwg = docs.Add
    docs.Item(dwgOrig).CopyObjects exportSS,
    newdwg.ModelSpace
    newdwg.SaveAs (dwgName)
    newdwg.Close
    <snip>

    replace with something like
    <snip>
    Set newdwg = OpenDbx 'assuming you have a function named
    open to open a dbxdoc
    'and return the dbxDocObject
    docs.Item(dwgOrig).CopyObjects exportSS, newdwg.ModelSpace
    newdwg.SaveAs (dwgName)
    Set newDwg = Nothing ' that closes the dbx doc
    <snip>
     
    Mark Propst, Feb 15, 2004
    #4
  5. SpeedCAD

    SpeedCAD Guest

    Hi Mark Propst...

    Yes, I understand it. But my idea is I make it only with ObjectDBX. I Create a drawing via ObjectDBX and next I use CopyObject.

    My idea is simulate the command WBLOCK, which is not in ObjectDBX.
     
    SpeedCAD, Feb 15, 2004
    #5
  6. SpeedCAD

    Jeff Mishler Guest

    SpeedCAD,
    Looks to me like you need to use the Add method, immediately SaveAs, close,
    then access via DBX. ObjectDBX was apparently designed to work with existing
    Objects, not create them.

    Jeff

    Create a drawing via ObjectDBX and next I use CopyObject.
     
    Jeff Mishler, Feb 16, 2004
    #6
  7. No, not really. A new AxDbDocument can be created
    from scratch and any number of objects can be copied
    into it or created in it directly.



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Feb 16, 2004
    #7
  8. SpeedCAD

    SpeedCAD Guest

    Hi Master Tony Tanzillo.

    How I can create a new AxDbDocument and copy objects to him with ObjectDBX?

    Thanks for all Master
     
    SpeedCAD, Feb 17, 2004
    #8
  9. You create a new AxDbDocument every time you use
    an object variable of that type.

    You don't have to use the Open() method to open an
    existing file, you can just treat the existing object as a
    new, unnamed DWG file.

    You copy objects into it using the CopyObjects method
    of the source document or database.



    AcadX for AutoCAD 2004 Beta 1
    http://mysite.verizon.net/~vze2vjds/acadx/AcadX16.zip
     
    Tony Tanzillo, Feb 17, 2004
    #9
  10. SpeedCAD

    Jeff Mishler Guest

    Thanks for the clarification, Tony. I could've sworn I looked at doing this
    and failed. But I just looked back at what I was testing and I was doing
    exactly what SpeedCAD had been asking ..... sometimes I just can't see the
    forest through the trees.....

    Jeff
     
    Jeff Mishler, Feb 17, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.