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

RE: How to activate a model in C# V8i

$
0
0

[quote user="HDR_Coder"]ForEachModel InActiveDesignFile.Models[/quote]

[quote user="HDR_Coder"]foreach(ModelReference model innewapp.ActiveDesignFile.Models)[/quote]

Is it an issue with temporary object lifetimes, or other misuse of the class?  There's a note in VBA help: You cannot use the New keyword to create a ModelReferences object.  Unfortunately, C# pays no attention to certain COM qualifiers such as noncreatable.

The VBA iterator uses property ActiveDesignFile.Models.  Nothing new or temporary is created.

The C# iterator creates an anoymous temporary variable to store the result of newapp.ActiveDesignFile.Models. As a new, unitialised, variable it contains no data. What happens if you use the VBA idiom in C#?

foreach (ModelReference model in app.ActiveDesignFile.Models)

Viewing all articles
Browse latest Browse all 7260


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