Export Dwg Sheets Views To Shared Coords

I’m going to go dig around, but I just saw this is possible from an updated plugin and I want to add it to my batch plot…

So on further investigation, you are required to enable ‘views as references’ to make the plugin work (you also have to specify a template). Not ideal, but I guess that’s the way in…

I am exporting to shared coordinates but the views aren’t taking notice, I’m not sure why.

Any assistance gratefully received.

I’m using a modified Python from @Alban_de_Chasteigner via Archi-lab via Genius Loci, at the minute… Here’s it further edited…

# Copyright(c) 2016, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net

# Import Element wrapper extension methods
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

import System
from System.Collections.Generic import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)


def ProcessList(_func, _list):
    return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )

def ProcessParallelLists(_func, *lists):
	return map( lambda *xs: ProcessParallelLists(_func, *xs) if all(type(x) is list for x in xs) else _func(*xs), *lists )

def Unwrap(item):
	return UnwrapElement(item)

folderPath = IN[0]

if isinstance(IN[1], list):
	views = ProcessList(Unwrap, IN[1])
else:
	views = list(Unwrap(IN[1]))

if isinstance(IN[2], list):
	names = IN[2]
else:
	names = list(IN[2])

RunIt = IN[4]

Version = Unwrap(IN[5])
dwgExportOptions = str(IN[3])
mergedViews = IN[6]
#if mergedViews == True:
#    sharedCoords = False #if we're going to export views separately, we'll want them in Shared Coordinates
#else:
#    sharedCoords = True

def ExportDwg(name, view, folder = folderPath):
	options = DWGExportOptions()
	options.FileVersion=Version
	options.GetPredefinedOptions(doc, dwgExportOptions)
	options.MergedViews = mergedViews
	options.SharedCoords = True #sharedCoords
	views = List[ElementId]()
	views.Add(view.Id)
	result = doc.Export(folder, name, views, options)
	return result

if RunIt:
	try:
		errorReport = None
		# run export
		ProcessParallelLists(ExportDwg, names, views)
		
	except:
		# if error accurs anywhere in the process catch it
		import traceback
		errorReport = traceback.format_exc()
else:
	errorReport = 'Please set the RunIt to True!'

#Assign your output to the OUT variable
if errorReport == None:
	OUT = 'Success'
else:
	OUT = errorReport

Cheers,

Mark

test.dyn (27.1 KB)

You should try without GetPredefinedOptions because you have probably two conflicting informations.


Internal in your ExportSetup and Shared in the python script.

It is working for me with
options.SharedCoords = True

Hmmm… my setup is to shared, it didn’t work so I added the SharedCoords to see if it helped…

Ooh though, I wonder if i’m not setting the predefined correctly, perhaps that’s part of the problem… I need to Get then Set them?

Give a try without the export Setup.

Hum, yes I commented that line out but it didn’t help. Thanks for the assistance BTW.

def ExportDwg(name, view, folder = folderPath):
	options = DWGExportOptions()
	options.FileVersion=Version
#	options.GetPredefinedOptions(doc, dwgExportOptions)
	options.MergedViews = mergedViews
	options.SharedCoords = True #sharedCoords
	views = List[ElementId]()
	views.Add(view.Id)
	result = doc.Export(folder, name, views, options)
	return result

It should work :
Revit :

Autocad:

That’s very odd. Do you know how we’d set the export options? There doesn’t appear to be a method for that…

Not sure what you want to do.
i have some nodes for export setup:

Thanks, I’ll have a look…

Here’s my rvt, & dyn…

When I make a dwg you can see that the spot coord isn’t matching my point in CAD…

test.dyn (27.6 KB)
test.rvt (2.4 MB)

Cheers,

Mark

I think I understand your failure.
Are you trying to export the sheet with shared coordinates ?
It’s not possible and the autodesk plugin doesn’t do that.
The autodesk plugin exports the sheet+the view. Then, it imports the xref view with the correct coordinates and the correct rotation.

Thanks for that, great knowledge.

Ok, so the problem with the plugin is that it doesn’t correctly title the dwg.

Hmm… So I can replicate some of their workflow? get views on sheets, export views, get centre point of view… But then I guess I would get stuck because I can’t use Dynamo to import a dwg reference into a dwg.

Perhaps I have to use the plugin then run a renaming Dynamo graph…

Thanks for that.

Mark

The easier method is to to use a lisp in autocad to import the external reference.
There are maybe some other possibilities with LinkDWG or DynamoCAD packages.

I wasn’t aware of those packages, I’ll have a look, thanks!

Edit: No, there doesn’t seem to be anything there for importing new instances. I have no knowledge of LISP so bit of a dead end for me.