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

Re: [V8i C# Addin] Creating an ApplicationElement --> How to instantiate DataBlock, how to add ApplicationElement to ActiveModelReference?

$
0
0

zCane75:
Datablock db is not instantiated, and I could find no way to instantiate it

From MicroStation VBA help: A program that runs outside of MicroStation or needs to create a DataBlock object in another MicroStation process should use app.CreateObjectInMicroStation ("MicroStationDGN.DataBlock") where app is an object reference to the Application object for that process

zCane75:

ActiveModelReference.AddElement is looking for an Element and throws  an exception that it cannot convert ApplicationElement to Element

That's C# being excessively picky about object types.  Looking at VBA help, it's clear that ApplicationElement inherits from Element.  However, that's inheritance in the COM sense and not inheritance in the true object-oriented sense that C# implements.  Try casting to Element and see if that works.


Viewing all articles
Browse latest Browse all 1677

Trending Articles



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