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: 

How to Get ExportDWGSettings Use Revit2014 API

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
beckhans
1402 Views, 7 Replies

How to Get ExportDWGSettings Use Revit2014 API

   I will Get a Revit ExportToDwg infomation.And I found a class named ExportDWGSettings.When I create an ExportDWGSettings instance (ExportDWGSettings.Create(Document,string)),Revit was down.

 

 

7 REPLIES 7
Message 2 of 8
Troy_Gates
in reply to: beckhans

Here is a quick example of creating DWGExportOptions:

 

DWGExportOptions dwgOptions = new DWGExportOptions();
dwgOptions.MergedViews = true;
dwgOptions.SharedCoords = true;

 You can change many of the export settings (like the 2nd and 3rd lines of code).

Message 3 of 8
beckhans
in reply to: Troy_Gates

Can you  give me a sample to get Export Dwg Layer Information?

Message 4 of 8
Aaron.Lu
in reply to: beckhans

See the example code, it is what you need?

 

var dwgSettingsFilter = new ElementClassFilter(typeof(ExportDWGSettings));
FilteredElementCollector settings = new FilteredElementCollector(RevitDoc);
settings = settings.WherePasses(dwgSettingsFilter);
foreach (ExportDWGSettings element in settings)
{
    var options = element.GetDWGExportOptions();
    var layerTable = options.GetExportLayerTable();
    foreach (var layerItem in layerTable)
    {
        var layerInfo = layerItem.Value;
        if (layerInfo.CategoryType == LayerCategoryType.Model)
        {
            var modifiers = layerInfo.GetLayerModifiers();
            foreach (var modifier in modifiers)
            {
                var modifierType = modifier.ModifierType; // get modifier type
                var separater = modifier.Separator; // get separator
            }
        }
    }
}

 



Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 5 of 8
Dale.Bartlett
in reply to: Aaron.Lu

Hoo boy, has anyone picked up the spelling mistake in the API?

var separater = modifier.Seperator;//.Separator; // get separator

 

Dale




______________
Yes, I'm Satoshi.
Message 6 of 8
Aaron.Lu
in reply to: Dale.Bartlett

Good catch.
and this is fixed in Revit 2015.


Aaron Lu
Developer Technical Services
Autodesk Developer Network
Message 7 of 8
Dale.Bartlett
in reply to: Aaron.Lu

I have tested the suggestion and extended slightly. One difficulty I have is returning the sub-category. LayerCategoryType categoryType = layerInfo.CategoryType will return "Model" or "Annotation", but I can't seem to return the sub-category ie "Air Terminal Tags" etc. I'm missing something simple... 

 

Possibly this is helpful for others:

<code>

public static void GetDWGExportSettings(RvtDoc pDoc)

{

var filter = new ElementClassFilter(typeof(ExportDWGSettings));

FilteredElementCollector settings = new FilteredElementCollector(pDoc);

settings = settings.WherePasses(filter);

string lstrExportTest = "Category Type"

+ "," + "Layer Name"

+ "," + "Color Name"

+ "," + "Color Number"

+ "," + "Cut Color Name"

+ "," + "Cut Color Number";

foreach (ExportDWGSettings element in settings)

{

DWGExportOptions options = element.GetDWGExportOptions();

ExportLayerTable layerTable = options.GetExportLayerTable();

// get others, not done yet

ExportLinetypeTable linetypeTable = options.GetExportLinetypeTable(); 

foreach (var layerItem in layerTable)

{

var layerInfo = layerItem.Value;

LayerCategoryType categoryType = layerInfo.CategoryType;

string layerName = layerInfo.LayerName;

string colorName = layerInfo.ColorName;

int colorNumber = layerInfo.ColorNumber;

string cutColorName = layerInfo.CutLayerName;

int cutColorNumber = layerInfo.CutColorNumber;

lstrExportTest = lstrExportTest

+ Environment.NewLine

+ categoryType.ToString()

+ "," + layerName

+ "," + colorName

+ "," + colorNumber.ToString()

+ "," + cutColorName

+ "," + cutColorNumber.ToString();

if (categoryType == LayerCategoryType.Model)

{

var modifiers = layerInfo.GetLayerModifiers();

foreach (var modifier in modifiers)

{

ModifierType modifierType = modifier.ModifierType; // get modifier type

string separater = modifier.Seperator;//.Separator (spelling fixed in 2015); // get separator

}

}

}

// write test file with name of export settings

FileTools fileTools = new FileTools();

fileTools.WriteTextFile(@"D:\_TempDelete\" + element.Name + ".txt", true, lstrExportTest);

}

}

 

<code>




______________
Yes, I'm Satoshi.
Message 8 of 8

Self answer:

<code>

var info = item.Value;

// element info

LayerCategoryType categoryType = info.CategoryType;

string categoryName = item.Key.CategoryName;

string subCategoryName = item.Key.SubCategoryName;

<code>

Dale




______________
Yes, I'm Satoshi.

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