Try this
# -*- 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])