Hi guys,
I want select all elements (and only them) in a level of a referenced file.
myFilter.ExcludeAllLevels
myFilter.ExcludeAllTypes myFilter.IncludeLevel ActiveModelReference.Levels(myLevel.Name) Set myCellElement = ActiveModelReference.Attachments(ModelName).Scan(myFilter)
"myFilter.IncludeLevel ActiveModelReference.Levels(myLevel.Name)" gives an error
How can I select all elements (and only them) of a level in a reference?
Thanks and bye.
Paolo
Hi Paolo,
please, use Insert > Insert code to share any code snippet! Really, it's annoying to read code formatted as plain text.
Paolo Maggiani said:I want select all elements (and only them) in a level of a referenced file.
I do not understand the code. What
Set myCellElement = ActiveModelReference.Attachments(ModelName).Scan(myFilter)
is expected to do? Accordingly to the variable name myCellElement it's CellElement class (maybe?), but Scan returns ElementEnumerator.
Paolo Maggiani said:How can I select all elements (and only them) of a level in a reference?
What types of elements you want to select?
Based on the code you posted it seems you want to selects cells. But cell itself (cell header) is not graphic element, so it cannot be selected based on level.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Something like this...
Sub SelectElementsInModel (ByVal oModel As ModelReference, ByVal levelName As String) Dim oFilter As New ElementScanCriteria Dim oLevel As Level ' Following line will throw error if model does not contain specified level Set oLevel = oModel.Levels (levelName) oFilter.IncludeLevel oLevel Dim oElements ElementEnumerator Set oElements = oModel.Scan (oFilter) Do While oElements.MoveNext oModel.SelectElement oElements.Current Loop End Sub
You must obtain the Level object from the DGN model. Usage...
SelectElementsInModel ActiveModelReference, "MyLevel"
SelectElementsInModel ActiveModelReference.Attachments ("MyModel"), "MyLevel"
Regards, Jon Summers LA Solutions
Jon, you are the number ONE. Thanks a lot :-)