addelementS method [VBA V8i SS3 fr ]

Bonjour,

I try to round off several lineelement

Dim Sc As ElementScanCriteria
Dim Ee As ElementEnumerator
Set Sc = New ElementScanCriteria
Sc.ExcludeAllTypes
Sc.IncludeType msdElementTypeLine
Set Ee = ActiveModelReference.Scan(Sc)
Dim LLanc As LineElement
Dim PtLL1 As Point3d
Dim PtLL2 As Point3d
Dim Ar() As Element
Do While Ee.MoveNext
    Dim LLNew As LineElement
    Set LLanc = Ee.Current
        With LLanc.startPoint
        PtLL1 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
        End With
        With LLanc.EndPoint
        PtLL2 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
        End With
    Set LLNew = CreateLineElement2(LLanc, PtLL1, PtLL2)
    ActiveModelReference.RemoveElement LLanc
    'ActiveModelReference.AddElement LLNew ' doesn't work if ee > 1024
Loop
RedrawAllViews

Doesn't work if the number of lines is up to 1024... 210

So I made a trick not very academic with « if..then.. end if » and « goto »

Suite:
If Ee.MoveNext Then
    Set LLanc = Ee.Current
    With LLanc.startPoint
    PtLL1 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
    End With
    With LLanc.EndPoint
    PtLL2 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
    End With
    Set LLNew = CreateLineElement2(LLanc, PtLL1, PtLL2)
    ActiveModelReference.RemoveElement LLanc
    ActiveModelReference.AddElement LLNew
    Ee.MoveNext
    GoTo Suite
End If
RedrawAllViews

I’d like tu use addelements method but i don’t see a example,

I ‘ve tried namedgroup, elementenumerator , arrays seems to be the best way but i failed

Does anyone have an example? Or help

Parents
  • What version (e.g. v10.x.y.z) of MicroStation, or other product, are you using?

    Doesn't work if the number of lines is up to 1024... 210

    I suspect that your problem is caused by creating new elements within your scan loop.  The scanner continues to enumerate each new line that you add. 

    Here are a couple of suggestions:

    1. Create a ScanCriteria object and limit your scan to LineElements
    2. Convert the ElementEnumerator to an array
    3. Iterate that array to create your new LineElements

     
    Regards, Jon Summers
    LA Solutions

Reply
  • What version (e.g. v10.x.y.z) of MicroStation, or other product, are you using?

    Doesn't work if the number of lines is up to 1024... 210

    I suspect that your problem is caused by creating new elements within your scan loop.  The scanner continues to enumerate each new line that you add. 

    Here are a couple of suggestions:

    1. Create a ScanCriteria object and limit your scan to LineElements
    2. Convert the ElementEnumerator to an array
    3. Iterate that array to create your new LineElements

     
    Regards, Jon Summers
    LA Solutions

Children
No Data