Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

[ABD SS5 VBA] Scan Reference and Copy Graphical Elements Failing

$
0
0

Hello all,

I have scoured the forums and internet for a solution, and think I found what I'm looking for, but my code is not working.  I wonder if AECOsim Building Designer is the culprit, although I have no real experience with VBA writing. I have a single reference file attached to a 3d design model, and I'd like to scan for all graphical elements in the reference and copy them to the active model. I'm getting an error when it comes time to copy.

Inserting a messagebox before the line that fails gives me a message for each element in the model, so I'm confident the scan is working. I thought maybe it was failing because I didn't have a CopyContext defined, but it didn't make a difference (not that I'm confident I defined the CopyContext correctly). Thanks for any help!

Dim myScanCriteria As ElementScanCriteria
Dim myElementEnumerator As ElementEnumerator
Dim myElement As Element
Dim myCopy As CopyContext

myCopy.AddElementToModel = True

Set myScanCriteria = New ElementScanCriteria
myScanCriteria.ExcludeNonGraphical

Set myElementEnumerator = ActiveModelReference.Attachments(1).Scan(myScanCriteria)
myElementEnumerator.Reset

While myElementEnumerator.MoveNext
    Set myElement = myElementEnumerator.Current
        If myElement.IsGraphical Then
        '''THE FOLLOWING IS THE LINE TO DEBUG'''
        ActiveModelReference.CopyElement myElement, myCopy
        End If
Wend
Regards,
Amador

Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>