# Extract Objects into new drawing

**URL:** <https://forum.dynamobim.com/t/extract-objects-into-new-drawing/67654>\
**Category:** Civil 3D\
**Created:** [August 29, 2021, 10:52pm UTC](https://forum.dynamobim.com/t/extract-objects-into-new-drawing/67654 "2021-08-29T22:52:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![david\_licona](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/david_licona/32/123672_2.png) [@david\_licona](https://forum.dynamobim.com/u/david_licona)\
**Post date:** [August 30, 2021, 4:25pm UTC](https://forum.dynamobim.com/t/extract-objects-into-new-drawing/67654/4 "2021-08-30T16:25:52Z")

</div>

Try this

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/e/6ee4d3e2762da06393ea25b36add0874bc97b629.png)

```auto
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 30 15:04:10 2021

@author: liconad
"""

# Load the Python Standard and DesignScript Libraries
import sys
import os
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')

# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

#Import references from 
import System
from System import *

#Establish global variables
aDoc = acapp.DocumentManager.MdiActiveDocument
cDoc = CivilApplication.ActiveDocument
ed = aDoc.Editor

def WBlock(path,oHand):
    """
	Create new drawing using WBlock method
	
	:path : filepath of new drawing to be created
    :oHand : Handle of pipe network to be exported 

	"""
    #call global variables inside the drawing
    global aDoc
    global cDoc
    global ed
 
    #Create an object id collection
    oic = ObjectIdCollection() 
    #Access the database
    with aDoc.Database as db:
        #Open transaction
        tr = db.TransactionManager.StartTransaction()
        with tr:
            #Get object ids (using handle)
            for handle in oHand :
                newhandleint = int(handle,16)
                hexa = Handle(newhandleint)
                oid = db.GetObjectId(False,hexa,oHand.index(handle))
                oic.Add(oid)
            #Create a new database
            with Database(True, False) as newdb:     
                #use WBlock method 
                db.Wblock(newdb, oic, Point3d.Origin, DuplicateRecordCloning.Ignore)
                #save new database as new drawing
                newdb.SaveAs(path, DwgVersion.Newest)
                return 'Completed'

WBlock(IN[0],IN[1])

```

---

_[View the full topic](https://forum.dynamobim.com/t/extract-objects-into-new-drawing/67654)._
