why cant I import ustation.dll in my project with visual studio 2008?
In this assebly there's a lot of interesting object but i cant use them. Why?
I mean that i cant use object like:
the problem is that if i declare an object of this type debugger say to me :
"cannot load file or assebly ustation" . Why?
thks.
Previdi.
Previdi: In this assembly there's a lot of interesting objects ... Bentley.Internal ...
Bentley.Internal ...
There are plenty of interesting functions in the MicroStation Development Library and plenty of interesting objects in the MicroStationDGN.Application COM server. There is seldom any reason to want to use anything but the public API.
What do you want to achieve? What is absent from the public API that prevents you attaining your goal?
Regards, Jon Summers LA Solutions
Is possible to use MDL function wrapper in c#?
I see in trhe MDLAPIFunction reference that some function has an "VBA Wrapper Declaration" but i cant to use it in c#.
Have you ever use it?
Andrea: Is there a way to set a property in MicroStationDGN.Application object about the instance of MIcrostation process i want to connect?
You have encountered one of the limitations of COM. As far as I know, there is no way to tell which instance of a COM server is supplying the interface that you are using. That is, if you have two instances of MicroStation XM, you don't know which one is providing your MicroStationDGN.Application object.
Our MicroStation Detector answers some, but not all, of your questions. The MicroStation Detector is freeware.
ok, i see it.
But how i can use solid elements with MicroStationDGN.Application object?
Andrea: How I can use solid elements with MicroStationDGN.Application object?
You can't. Another reason to use C++ and call the mdlKI_xxx (Kernel Independent) MDL API.
IMHO I would follow Jon Summers advice of stay the course with MDL and update the code to C++ Native code. You then have full access to the MDL api without having to dllimport and wrestle with Managed to UnManaged code. If you really need to move to C# then I would suggest that you isolate the solids api into an UnManaged dll that you can call with some simple calls.
HTH,
Mark Anderson [Bentley]
mark anderson [Bentley]
Visit me at https://communities.bentley.com/communities/other_communities/bentley_innovation/default.aspx
sorry, but i don't find the way to use MicrostationApi.
Is there some code example? Have u some tips?
Thnks a lot.
Andrea.
As BDN member you can see this http://communities.bentley.com/forums/permalink/33979/34135/ShowThread.aspx#34135
There is an easy to understand example by Piotr that describes how to build DLL in C++ with MDL...
Since using C# with the ustation.dll and getting started with the MicroStationAPI classes are really two seperate subjects I would suggest that you start a new thread. In this new thread it would help if you provided some information on what you need to achieve and if there is any legacy code involved. In short the MicroStationAPI classes are just startting in MicroStation V8 XM Edition and are more fully built up in MicroStation V8i. You can download the MicroStation V8i SDK to get more complete documentation and some updated examples that use the new API.
there's a way to get property of a solid element in c#(External application)? Property like volume, centroid, face area etcc?
Grazie.
This consoleApplication will write properties of selected solid elements...
using System; using System.Collections.Generic; using System.Text; using Bentley.Interop.MicroStationDGN; using SRIS = System.Runtime.InteropServices; using BMI = Bentley.MicroStation.InteropServices; using BIM = Bentley.Interop.MicroStationDGN; namespace ExternalCOMAndMDL { class Program { static void Main(string[] args) { BIM.ApplicationObjectConnector ustnConnector; BIM.Application ustn; try { ustnConnector = (BIM.ApplicationObjectConnector) SRIS.Marshal.GetActiveObject("MicroStationDGN.ApplicationObjectConnector"); ustn = ustnConnector.Application; } catch { Console.WriteLine("No MicroStation is running..."); Console.ReadKey(); return; } if (ustn.ActiveModelReference.AnyElementsSelected != true) { Console.WriteLine("No elements are selected in " + ustn.Caption); Console.ReadKey(); return; } BIM.ElementEnumerator ee; BIM.Element cEl; System.String cExpression; double volume, area, cX, cY, cZ; ee = ustn.ActiveModelReference.GetSelectedElements(); Console.WriteLine("Processing " + ustn.Caption); while (ee.MoveNext()) { cEl = ee.Current; cExpression = "mdlMeasure_volumeProperties(&tcb->uc_a[0]," + "&tcb->uc_a[1], ((void*)0), &tcb->uc_a[2], " + "((void*)0), ((void*)0), ((void*)0), ((void*)0),"+ "((void*)0), ((void*)0), " + cEl.MdlElementDescrP(false) + ", 0.1, ((void*)0))"; if (0 == (int) ustn.GetCExpressionValue(cExpression, null)) { volume = (double) ustn.GetCExpressionValue("tcb->uc_a[0]", null); area = (double) ustn.GetCExpressionValue("tcb->uc_a[1]", null); cX = (double) ustn.GetCExpressionValue("tcb->uc_a[2]", null); cY = (double) ustn.GetCExpressionValue("tcb->uc_a[3]", null); cZ = (double) ustn.GetCExpressionValue("tcb->uc_a[4]", null); Console.WriteLine( "Volume: " + Math.Round(volume, 5).ToString() + " Area: " + Math.Round(area, 5).ToString() + " Centroid: " + Math.Round(cX, 3).ToString() + " " + Math.Round(cY, 3).ToString() + " " + Math.Round(cZ, 3).ToString()); } } Console.ReadKey(); } } }
try this (from the docs)
Solid Properties
Sub ShowSolidPropertyStrings(ele As Element) Dim oPH As PropertyHandler Set oPH = CreatePropertyHandler(ele) oPH.SelectByAccessString "Description" If oPH.GetValue = "Smart Solid" Then ShowDisplayString oPH, "Description" ShowDisplayString oPH, "NumElems" ShowDisplayString oPH, "RotationAngle" ShowDisplayString oPH, "ScaleX" ShowDisplayString oPH, "ScaleY" ShowDisplayString oPH, "ScaleZ" End If ShowDisplayString oPH, "Volume" ShowDisplayString oPH, "SurfaceArea" End Sub Sub ShowSolidPropertyValues(ele As Element) Dim oPH As PropertyHandler Set oPH = CreatePropertyHandler(ele) oPH.SelectByAccessString "Description" If oPH.GetValue = "Smart Solid" Then ShowValue oPH, "NumElems", False, False ShowValue oPH, "RotationAngle", False, False ShowValue oPH, "ScaleX", False, False ShowValue oPH, "ScaleY", False, False ShowValue oPH, "ScaleZ", False, False End If ShowValue oPH, "Volume", False, False ShowValue oPH, "SurfaceArea", False, False End Sub Private Sub ShowDisplayString(oPH As PropertyHandler, accessString As String) On Error GoTo HandleError If Not oPH.SelectByAccessString(accessString) Then Debug.Print "NOT FOUND!!" Else Debug.Print oPH.GetDisplayString End If Exit Sub HandleError: Debug.Print Err.Description End Sub Private Sub ShowValue(oPH As PropertyHandler, accessString As String, isDlong As Boolean, isPoint As Boolean) On Error GoTo HandleError If Not oPH.SelectByAccessString(accessString) Then Debug.Print "NOT FOUND!!" Else If isPoint Then Dim pnt As Point3d pnt = oPH.GetValueAsPoint3d Debug.Print "(" & pnt.X & "," & pnt.Y & "," & pnt.Z & ")" ElseIf isDlong Then Debug.Print DLongToString(oPH.GetValueAsDLong) Else Debug.Print oPH.GetValue End If End If Exit Sub HandleError: Debug.Print Err.Description End Sub
You should property handlers from external applications.