Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Problem in Revit 2018. Document.Import Method (String, DWGImportOptions, View, ElementId)
Application imports DWG files to Revit that way:
DWGImportOptions dWGImportOptions = new DWGImportOptions
{
ThisViewOnly = true,
ColorMode = ImportColorMode.BlackAndWhite,
VisibleLayersOnly = true,
Unit = ImportUnit.Default,
Placement = ImportPlacement.Origin,
OrientToView = true
};
next load Line Weights file:
IList<int> lineWeights = new List<int>();
using (FileStream fileStream = new FileStream(lineWeightsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (StreamReader streamReader = new StreamReader(fileStream))
{
string line;
while ((line = streamReader.ReadLine()) != null)
{
int intLine;
if (int.TryParse(line, out intLine))
lineWeights.Add(intLine);
}
streamReader.Close();
}
dWGImportOptions.SetLineWeights(lineWeights);loaded file is attached.
Finally Import:
document.Import(pathDWG, dWGImportOptions, viewPlan, out elementId)
In Revit 2015...2017 works fine, but the same code in Revit 2018 rise exception:
"The array of line weights is not valid; either it contains less than expected 255 values, or one or more values are out of range 1 to 16
Parameter name: options"
I reality array contains 255 values, all of them in range 1 to 16. If try import manually (in Revit user interface) using the same file, works fine.
Error happens when import by application doing.
Solved! Go to Solution.