Using AssembleComplexStringsAndShapes

Hi all

I've been having a problem with the AssembleComplexStringsAndShapes, which was suggested in this forum as the method for combining a set of lines into a complex string as it would deal away with the problem of having to sort or order the lines which would otherwise be necessary using the CreateComplexString method.

However, as much as I have tried, there is a type mismatch error in the AssembleComplexStringsAndShapes line, even though I am inputting a ChainableElement() array which is what the method seems to want based on its definition.

I am hopeful that I am missing a notation thing somewhere but I have tried the various options (including sending in other arrays and assigning the ChainableElement() array differently but nothing seems to be that missing link!

Any help is greatly appreciated.

Cheers

 Koit

Private Sub StringChainer(levelName As String)

    ' Set up corresponding level object
    Dim oLevel As Level
    Set oLevel = ActiveDesignFile.Levels(levelName)

    ' Set up scan criteria
    Dim oScanCriteria As ElementScanCriteria
    Set oScanCriteria = New ElementScanCriteria
    
    oScanCriteria.ExcludeAllLevels
    oScanCriteria.ExcludeAllTypes
    
    oScanCriteria.IncludeLevel oLevel
    oScanCriteria.IncludeType msdElementTypeLine
    
    Dim oEnumerator As ElementEnumerator
    Set oEnumerator = ActiveModelReference.Scan(oScanCriteria)
    
    Dim oElements() As Element
    Dim oStringElements() As ChainableElement
    oElements = oEnumerator.BuildArrayFromContents
    
    ReDim oStringElements(0 To UBound(oElements))
    
    Dim i As Long
    For i = 0 To UBound(oElements)
        Set oStringElements(i) = oElements(i)
    Next i
        
    Dim chained As ComplexStringElement
    Set chained = AssembleComplexStringsAndShapes(oStringElements)
    
    ' Add the element to the active model (whether or not it's displayed)
    ActiveModelReference.AddElement chained
    
End Sub
Parents Reply
  • Jan

    Thanks for the note. I looked back into the help file and noticed how silly the original assigning was -- namely, I read the remarks line "Output Elements consist of ChainableElements and/or ClosedElements." and that made me think it would give the result I expected...

    The first line in the help is clearly at odds with it though.

    Thanks again for pointing out the obvious!

    Koit

    NB! I think I accidentally saved it as a DWG; it was meant to be a DGN... Had been a long day (when aren't they...) when I replied to you last.
Children
No Data