Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all 4331 articles
Browse latest View live

[V8i VBA] Search Text Node for Matching String

$
0
0

I'm an engineer trying to simplify life with some VBA code for Microstation V8i.  I'm trying to search a text node for matching text.  I can only find sample code for searching text objects.  Can anyone help me modify this code?  I'm thinking I need to use the GetSubElements member but I cant figure out how to use it.

Dim TextElem As TextElement
Dim MyMod As ModelReference
Set MyMod = Application.ActiveModelReference
Dim MyElems As ElementEnumerator
Set MyElems = MyMod.GetSelectedElements
Dim MyElem As Element''stuff''Searches for matching StrNumb Text in active model
    Set MyElem = MyElems.Current'only searches for matching element type
    Select Case MyElem.Type
        Case msdElementTypeText
            Set TextElem = MyElem'If selection matches element type, attempts to match text
            If InStr(1, TextElem.Text, StrNumb) > 0 Then''rest of code'

Thanks,

PS is it possible to place a Note with VBA? if so can anyone point me in the right direction for some example code?


What are the differences between the MacroStation .Net and MDL Native Code APIs?

$
0
0

I took a quick look at MicroStationAPI.chm and MSTNPlatformNET.chm. Seems MicroStationAPI are Native C++/C APIs, and MSTNPlatformNET are .Net APIs like C#, and VB net. Both have object model. But the Object Models of MicroStationAPI and MSTNPlatformNET are different, e.g. MSTNPlatformNET  has Application object, but MicroStationAPI  has not. So what should I learn MSTNPlatformNET  or MicroStationAPI ?  Why not have consistent Object Model? Another question does MicroStation C++ API support binary compatibility, e.g. what will happen if a C++ addin dll built on MicroStation Version 1, and run on a later Version 2 without building again?

Thanks.

[V8i VBA] Excel Object Library

$
0
0

Hello 

I am writing a macro in Microstation that uses a lot of Excel VBA.

It works fine on my machine, but whenever someone else tests it with different library present we obviously got crashes.

Question is: is there a way (in code) to attach the Excel Object Library that is present (I've met versions 12, 15 and 16 - I got 15) and not in references?

the functions I'm using are present in all of them and its just the matter of ticking box in references for everything to work ok, but i want to protect it with password and distribute it for external purpose as well.

thank you

Michal Kurzewski

How to attach a MSLink to an Element

$
0
0

Hi Everyone,

I am trying to write an MDL in C/C++ that should attach Meta-Data to Elements in an external MDB-Database.

I wrote already Code to make sure that the correct Database (DB) is attached, but now I have Problems how to attach the created MSLink to an element.

There is one function to write the Attributes into the DB and retrieve the MSLink:

Private int writeObjatt
(
UInt32   *mslink,  
char   *tableName, 
char   *objidP, 
char   *oclassP, 
char   *ocodeP,  
char   *icodeP, 
char   *statusP 
)  { char   insertStmt[MAXSTATEMENTLENGTH];   char  dbColumns[5*TAGSTRINGVALLENGTH+10];  char  dbValues[5*TAGSTRINGVALLENGTH+10];  int   ret=-1, test1=-1;  // Writing the column-names into a string sprintf(dbColumns, "objid, oclass, ocode, icode, status");  // writing the values into a string sprintf(dbValues, "'%s','%s','%s','%s','%s'", objidP, oclassP, ocodeP, icodeP, statusP);  // writing the finlal SQL-Insert-Statement into a string sprintf(insertStmt, "insert into %s (%s) values (%s)", tableName, dbColumns, dbValues);  fprintf(f_log, "\t(In tab2db_writeObjatt): Insert-Statement= '%s'\n", insertStmt);  // Writing into Database test1 = mdlDB_addRowWithMslink(mslink, tableName, insertStmt);   if(test1 == SUCCESS) ret=SUCCESS;  return ret;  }
I thought, that this would write the given Attributes into the DB and that I 'only' would have to attach this MSLink to an element. (The return-value from this function Shows 'SUCCESS' and the values are correctly written into the DB!). (There is an 'mscatalog' table defined in the DB and as well another table <tableName> that contains apart of the 'mslink'-column 5 other columns, defined as Texts[TAGSTRINGVALLENGTH]).
The Elements for which the Meta-data should be attached are handled in a Callback-function (from 'mdlScanCriteria_setElemRefCallback') that is shown below:
Private int CallbackFunct
(
ElementRef		elR,
void			*callbackArg,	// Structur with arguments for Callback-function
ScanCriteriaP	scP				// Pointer to ScanCriteria-Object
)
  {
	int		ret=SUCCESS;
	int 	test=-1, status=-1;
	int 	elType;			// Element-Typ
	UInt32		mslink;		// MSLink-Number
	CallbackArgStruct	*data = (CallbackArgStruct*)callbackArg;
	MSElementP	elP;
	EditElemHandle eh(elR, mdlScanCriteria_getModel(scP));	// Element-Handler
	char t_objidP[TAGSTRINGVALLENGTH], t_oclassP[TAGSTRINGVALLENGTH], t_ocodeP[TAGSTRINGVALLENGTH];
	char t_icodeP[TAGSTRINGVALLENGTH], t_statusP[TAGSTRINGVALLENGTH];

	// Checking Element-Type
	elType = eh.GetElementType();

	// Pointer to element created from ElemeHandle
	elP = eh.GetElementP();

	if(elType==CELL_HEADER_ELM || elType==LINE_ELM || elType==LINE_STRING_ELM || elType==LINE_STRING_ELM) {

		[...]	// Retrieve Attribute-values from element

		// Writing Attributes into Database using the above mentioned function
		test = writeObjatt(&mslink, "objatt", t_objidP, t_oclassP, t_ocodeP, t_icodeP, t_statusP);

		//?????  How to attach the MSLink to the MSElement ?????//

		// REPLACING the old element instead of rewriting in reason of different Size after MSLink-Attachment ??
		status = ReplaceElement (elP);	//???

		if(test != SUCCESS) ret=-1;
	}
	return ret;
  }

So my Problem is, how I can attach the created MSLink to the Element it belongs to and how do I have to rewrite/replace it afterwards!
I tried to figure it out from the database-example 'gis.ma', but it seems to do something different in the sub-function 'gis_writeParcel', therefore I couldn't solve my Problem.
Many thanks for your help in advance,
Ines Wieland

C# code examples (MicrostationVBA.chm)

$
0
0

Where can I find good documents with C# examples about Microstation COM objects. The only document I can find so far for this purpose is this MicroStationVBA.chm file in the Microstation installation folder. Do we have the same document with C# code examples? Can we find other useful documents with C# code examples?

[CONNECT C++] How to get the direction of the curve "thickness"

$
0
0

Hi,

I noticed curve has the property "thickness", if set "thickness" value as a positive number, the curve will be shown as a surface in the application.

My question is

(1) What's the definition of the direction of "thickness"? Take line as an example, there are several directions perpendicular to that line, how to define its direction?

(2) Are there any APIs to get the direction of "thickness"? Or are there any APIs to get the information of the plane where the curve is located at?

Invoking V8i COM API type global functions

$
0
0

Trying to use a global function of type Matrix3d, but having an error with it. See the code below. What do I have to add to make it work?

Help with code for a batch process file

$
0
0

I'm trying to create a batch process that deletes the design history of a file and then initializes it.  What code do I need to have in my script such that it selects "OK" in the dialogue window that appears after each command?


Create a line with it's total length shown automatically

$
0
0

Hi,

I would like to create a program/tool to create a smart line (from user's pick point) and then the program should automatically show the length of the drawing line

[CONNECT] MicroStationAPI Documentation Generated Incorrectly

$
0
0

While browsing the MicroStationAPI documentation I came across Database Connectivity.  The words I read didn't seem to match the page layout on screen...

The function headline of mdlDB_openCursorVersionWithID() lies at the bottom of the page, but its description is at the top of the page.  The function headline and description of mdlDB_deletePendingVersion() are sandwiched between.

No doubt this is an artefact of the automatic document generator.  There may be other manifestations of this problem, but I'm not going looking for them  8-)

Run Addin without UI

$
0
0

I am using the COM API through Interop assembly code below to scan the document for some reporting. 

public Application ustnApp = new ApplicationClass();

ustnApp.OpenDesignFile(fileName);

  (Blank UI)

Interestingly, when I run it in CONNECT i always get his blank UI popping up, while the blank UI is NOT showing up if I use V8i. How can that be possible?

If I don't want any UI to show up (only want the code to quietly read the Microstation file and generate the report), what should I do?

Thanks,

[Connect C#] Clip Element

$
0
0

Hello,

in V8i I use this class in an Addin to Clip elements.

public class ClipService
    {
        [DllImport("ustation.dll", EntryPoint = "mdlClip_element", CallingConvention = CallingConvention.Cdecl)]
        private static extern int mdlClip_element(ref int insideEdPP, ref int outsideEdPP, int inputEdP, int modelRef, int clipP, int view);

        [DllImport("ustation.dll", EntryPoint = "mdlClip_getFence", CallingConvention = CallingConvention.Cdecl)]
        private static extern int mdlClip_getFence(ref int clipPP);

        [DllImport("ustation.dll", EntryPoint = "mdlClip_free", CallingConvention = CallingConvention.Cdecl)]
        private static extern int mdlClip_free(ref int clipP);

        [DllImport("ustation.dll", EntryPoint = "mdlClip_fromElement", CallingConvention = CallingConvention.Cdecl)]
        private static extern int mdlClip_fromElement(ref int clipPP, int pElement, int outside, int pOutputTransform, int view);

        private int clipPP;
        private int modelRefP;
        private int viewIndex;

        /// <summary>
        /// Konstruktor
        /// </summary>
        /// <param name="clip">Elememt an dem geschnitten werden soll</param>
        /// <param name="modelRef">ModelReference in dem die Elemente liegen</param>
        public ClipService(Element clip, ModelReference modelRef, View view)
        {
            var fence = Utilities.ComApp.ActiveDesignFile.Fence;
            fence.DefineFromElement(view, clip);

            viewIndex = view.Index - 1;
            clipPP = 0;
            modelRefP = modelRef.MdlModelRefP();
            var ret = mdlClip_getFence(ref clipPP);
            //var ret = mdlClip_fromElement(ref clipPP, clip.MdlElementDescrP(false), MSKonstanten.FALSE, 0, viewIndex);
        }

        /// <summary>
        /// Destruktor (Speicher freigeben)
        /// </summary>
        ~ClipService()
        {
            if (clipPP != 0)
            {
                mdlClip_free(ref clipPP);
            }
        }

        /// <summary>
        /// Element wird geclippt
        /// </summary>
        /// <param name="elementToClip">Element welches geclipped werden soll</param>
        /// <returns>Clip Ergebnis oder null</returns>
        public Element DoClip(Element elementToClip)
        {
            int insideEdP = 0;
            int outsideEdP = 0;

            var ret = mdlClip_element(ref insideEdP, ref outsideEdP, elementToClip.MdlElementDescrP(false), modelRefP, clipPP, viewIndex);
            if (insideEdP != 0)
            {
                return Utilities.ComApp.MdlCreateElementFromElementDescrP(insideEdP);
            }
            return null;
        }
    }

Now I search for a clip function in Connect Update 6.

Can someone give me a hint? Is in the DgnPlatformNET Namespace any function to clip elements (line - line, line - shape)?

Thanks

Martin

[CONNECT C++] MSValueDescr

$
0
0

The CONNECT MicroStationAPI introduces the MSValueDescr, which is a wrapper around ValueDescrValueDescr is a variant data type.

Memory Management

With a ValueDescr, the programmer had to take care of memory management for Unicode and multibyte strings.  Is MSValueDescr smarter?  That it, does it manage memory automatically — for example, if I store a string in an MSValueDescr, does its destructor free that string?

SetDouble()

MSValueDescr has a number of methods to set the stored value.  Most of them return nothing, with the exception of MSValueDescr.SetDouble(), which returns a StatusInt.  What does that return value indicate when setting a double?

Microstation SDK

$
0
0

Hi,

Where may I download Microstation SDK for Microstation Connect Edition Update 6?

I don't find any link of any SDK in Software Download page.

Thanks for help.

Best Regards,

Jean-Claude

[CONNECT C++] How to use MFC Classes CString/CStdioFile

$
0
0

Im not sure that this is even possible with the CONNECT API but is it possible to use the standard MFC classes CString, CStdioFile etc? I am trying to port some legacy code into a working CONNECT application and am running into compiler errors when I include afx.h or afxwin.h. Then I found msmfc.h, tried to include it and get another set of errors, this file seems to just deal with MFC dialogs anyway.

When I search this forum and the API docs I find several posts/entries about using native windows/dialogs but cant find any references about other classes.

Loren.


[CONNECT] Using the ECSchema Editor 1.0

$
0
0

I'd like to use the ECSchema Editor 1.0 to examine my Item Type schema.  The first problem I come across is that my schema is stored in a MicroStation DGNLib and the ECSchema editor can open only XML files.

How can I export my Item Type schema to an XML file?

[CONNECT C++] DgnECInstanceIterable

$
0
0

I'm attempting to enumerate EC instances in a DGN model...

DgnPlatform::FindInstancesScopeOption option (DgnECHostType::Element);
FindInstancesScopePtr scope = FindInstancesScope::CreateScope (*Utilities::GetActiveDgnFile (), option);
ECQueryPtr query = QueryFactory::CreateAreaElementQuery (); UInt32 count { 0 }; DgnECManagerR = SchemaFactory::GetDgnEcManager (); DgnECInstanceIterable instances = manager.FindInstances (*scope,  *query, &count); msg = "Found "; msg += count; msg += " instances"; msg.Output (); // Message Center displays 'Found 8 instances' for (DgnECInstanceIterable::const_iterator it = instances.begin(); it != instances.end(); ++it) { // Compiles and runs OK (but does nothing) }

When I attempt to dereference the iterator I get a run-time crash...

... as before
for (DgnECInstanceIterable::const_iterator it = instances.begin(); it != instances.end(); ++it)
{
   //  Compiles OK but demolishes MicroStation at run-time
   DgnECInstancePtr 	instance = *it;
}

I don't understand the dereference operator in DgnECInstance.h...

typedef iterator_impl::reference reference;
DGNPLATFORM_EXPORT const_iterator (iterator_impl impl);
DGNPLATFORM_EXPORT reference operator*() const;

Because, of course, we cannot see the internals of iterator_impl

[CONNECT C++] Construct ECQuery to get Item Types

$
0
0

If I build an ECQuery like this, to search for, say, DGN shape elements...

ECQueryPtr query = ECQuery::CreateQuery (L"BaseElementSchema",   L"MstnClosedBoundary", true);

Then use it with DgnECManager.FindInstances (... , *query, ...) I get the result I expect.

How do I create a query for my Item Type?  What should the schemaName and className arguments be?  The name of my Item Type library?  The internal name of that library?  The Item Name?  Something else? The screenshot below shows the Item Types dialog with my AreaAnnotator library details...

[CONNECT C++] EC SearchClass

$
0
0

SearchClass Struct Reference

#include <ECQuery.h>

EC SearchClass seems to be an orphan.  It's defined but never used, at least publicly.  Perhaps it's used internally in ECQuery methods that take a schemaName, className pair?

[CONNECT C++] ECQuery::SetPropertyValuePreFilter

$
0
0

I would like to fetch instances of my Item that match a particular property value.  I would like to add a property filter to my ECQuery.  Method  query->SetPropertyValuePreFilter() looks like it should do the job.

However, it takes a IECPropertyValueFilter argument, and I don't see how to populate that struct.  Do I use IECPropertyValueFilter.Accept (ecPropertyValue)?

The only way to make an ECPropertyValuePtr is ECPropertyValue::GetPropertyValue (IECInstanceCR instance, WCharCP propertyAccessor).  But that seems somewhat circular, because it's instances that I'm wanting to find using my ECQuery.

Viewing all 4331 articles
Browse latest View live


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