Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DGN Export settings

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
R.van.den.Bor
910 Views, 11 Replies

DGN Export settings

Hi there,

 

I'm trying to automate DGN export in Revit 2014/2015. I have tried this code :

 

public bool ExportDGN(Document document, View view)
{
bool exported = false;
// Get predefined setups and export the first one
IList<string> setupNames = BaseExportOptions.GetPredefinedSetupNames(document);
if (setupNames.Count > 0)
{
// Get predefined options for first predefined setup
DGNExportOptions dgnOptions = DGNExportOptions.GetPredefinedOptions(document, setupNames[0]);

// export the active view if it is printable
if (document.ActiveView.CanBePrinted == true)
{
ICollection<ElementId> views = new List<ElementId>();
views.Add(view.Id);
exported = document.Export(Path.GetDirectoryName(document.PathName),
Path.GetFileNameWithoutExtension(document.PathName), views, dgnOptions);
}
}

return exported;

 

 

However, this line doesn't return any setups.

IList<string> setupNames = BaseExportOptions.GetPredefinedSetupNames(document);

 

I have tried everything :

IList<string> setupNames = DGNExportOptions.GetPredefinedSetupNames(document);

IList<string> setupNames = ACADExportOptions.GetPredefinedSetupNames(document);

IList<string> setupNames = CADExportOptions.GetPredefinedSetupNames(document);

 

 

I receive the setups for DWG, but not for DGN.

Does anyone experience the same problem ?

 

Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
11 REPLIES 11
Message 2 of 12
Aaron.Lu
in reply to: R.van.den.Bor

Dear R:

 

I don't see any problem in your code.

That might because there is no predefined DGN settings in your document.

Please check Revit>Export>CAD Formats>DGN>Select Export Setup, in the combobox did you see any predefined settings? if not, then Click the "Modify Export Setup" button, in the popup dialog, in the left bottom corner, click "New Export Setup"



Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 3 of 12

Hello Aaron,

Here is where Revit has some strange behavior.

When I export to dwg and there is no export setup (actually it says 'in-session export setup'), there is still an autocad drawing exported.

When I try the same for dgn, there isn't ??

So 'in-session export setup doesn't work for dgn. When I make an export setup first and use this one, the dgn export works.

SO, my question is, why is there this difference and how can I export to dgn with the default standard in-session export setup ?



Met vriendelijke groet,

ing. Remy van den Bor
ICN Solutions B.V.


[icnsolutions-logo.jpg]


Europalaan 14-18, 5232 BC 's-Hertogenbosch
Postbus 3302, 5203 DH 's-Hertogenbosch
Telefoon +31 (0)73 750 6 750
E-mail R.van.den.Bor@ICN-Solutions.nl
Internet www.ICN-Solutions.nl
Twitter www.twitter.com/icnsolutions
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 4 of 12
Aaron.Lu
in reply to: R.van.den.Bor

If DWG export only has "in-session export setup", then how did you get the ExportOptions argument? because you can query an existing one, you should create a new one, if that is the case, then for DGN you can also create a new one.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 5 of 12

Well,

I've tried in Revit 2014 and 2015.

If have made 1 setup called DWGsetup and I've made 1 dgn setup called DGNSetup.

var dwgExportOptions = DWGExportOptions.GetPredefinedSetupNames();
This will return a value of 1 being the DWGsetup.

var dgnExportOptions = DGNExportOptions.GetPredefinedSetupNames();
This will return a value of 0 and NOT the expected DGNsetup ???

Even this :

var baseExportOptions = BaseExportOptions.GetPredefinedSetupNames();
This returns a value of 1 being the DWGsetup, but I would expect to get 2 setups back, being the DWGsetup AND DGNsetup. ???

So, every which way I try I only get a collection of 1 setup back, and that's the DWG setup.


Met vriendelijke groet,

ing. Remy van den Bor
ICN Solutions B.V.


[icnsolutions-logo.jpg]


Europalaan 14-18, 5232 BC 's-Hertogenbosch
Postbus 3302, 5203 DH 's-Hertogenbosch
Telefoon +31 (0)73 750 6 750
E-mail R.van.den.Bor@ICN-Solutions.nl
Internet www.ICN-Solutions.nl
Twitter www.twitter.com/icnsolutions
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 6 of 12
Aaron.Lu
in reply to: R.van.den.Bor

Would you please upload your rvt file?
I did a test on Revit 2015, if only "in-session export setup" exists for both settings, I will get 0 options from both of them.
If I create 1 setting for both of them seperately, it returns 1 for DWG and 1 for DGN.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 7 of 12
Aaron.Lu
in reply to: R.van.den.Bor

Wait a moment, I found those methods always return the same list of strings...

e.g.
var ops = DGNExportOptions.GetPredefinedSetupNames(this.Document);
var ops2 = DWGExportOptions.GetPredefinedSetupNames(this.Document);
var ops3 = DXFExportOptions.GetPredefinedSetupNames(this.Document);

all of the above will return the same name list, did you see the same problem?


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 8 of 12
R.van.den.Bor
in reply to: Aaron.Lu

Yes, i did. All methods always return the setups for the dwg. It will never return the dgn setups.
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).
Message 9 of 12
Aaron.Lu
in reply to: R.van.den.Bor

Ok, I will report an issue for it. Thanks very much to raise this problem.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 10 of 12
Aaron.Lu
in reply to: R.van.den.Bor

There is another workaround: using ElementFilter to Filter ExportDGNSettings.

http://adndevblog.typepad.com/aec/2014/12/revitapi-how-to-get-dwgexportoptions.html

you can have a try


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 11 of 12
Aaron.Lu
in reply to: R.van.den.Bor

REVIT-59240 is logged for this issue. thanks.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 12 of 12

Yes, with the filtered collection it works 🙂 Thanx for the help.


Kind regards,

ing. Remy van den Bor
ICN Solutions B.V.


[icnsolutions-logo.jpg]


Europalaan 14-18, 5232 BC 's-Hertogenbosch
Postbus 3302, 5203 DH 's-Hertogenbosch
Telefoon +31 (0)73 750 6 750
E-mail R.van.den.Bor@ICN-Solutions.nl
Internet www.ICN-Solutions.nl
Twitter www.twitter.com/icnsolutions
Kind regards,
Remy van den Bor
ICN Solutions B.V.
Liked this post or found it usefull, don't forget the Kudo It won't hurt (at least not me).

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community