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

[v8i] Fence.GetContents enumeration slowdown vs v8XM

$
0
0

Hi all,

I'm hoping someone might be able to suggest a simple fix to an issue I'm experiencing.

My current task is generating a dataset for viewing at 1:25,000 scale from our base mapping which is created for main viewing at 1:250 - 1:1250 when printed.

This involves a fair bit of "clash detection" for placing text at the new size / locations and spatial analysis for grouping elements with matching attribution.

During this process I've been using (very successfully under v8 XM) a lot of fence.GetContents, with fences defined from elements created in VBA, but not added to the ActiveModel. This has been working brilliantly under v8 XM, but unfortunately v8 XM won't start unless there is an "active screen" it appears, i.e. a live user - not at the Logon Screen or connected via Remote Desktop (it otherwise crashes with a DirectX initialisation error - This "build" process must run nightly on a headless machine, which unfortunately we cannot leave "logged in" with screensaver disabled.).

v8i seems happy to start without such a live session, but when running the exact  same VBA code under v8i any sections which rely on fence scanning run at 1/4 - 1/5th the speed as v8 XM - timed by wrapping kernel32 to get a Millisecs counter in VBA.

Essentially I'm asking if there any additional settings introduced in v8i to control Fences and enumeration of their contents?

Or is slowness of fence enumeration a known issue?

 


[V8i, MDL]Customized mdlDialog_fileOpen make V8i crash

$
0
0

Hi All,

I have a folder brower dialog worked well in MicroStation V8-2004, but when I upgrade it to V8iSS3 it always makes MicroStation crash. I am still using PureMDL to do it.

      char saveDir[MAXFILELENGTH];
      mdlDialog_fileOpen(saveDir, NULL, DIALOGID_BrowseFolder, "*.DGN", "*.*", "D:\\", "Save file to:");

Resource definition is as below:

 DialogBoxRsc DIALOGID_BrowseFolder =
{
    DIALOGATTR_MODAL | DIALOGATTR_ALWAYSSETSTATE | DIALOGATTR_DEFAULT,
    42.5*XC, 21*YC, NOHELP, MHELP, NOHOOK, NOPARENTID, "Select folder:",
   {
   {{10*XC,     YC, 27*XC, 0}, Text,       TEXTID_FileOpenFileName, ON|HIDDEN, 0, "File Name:", ""},
   {{12*XC, 17.3*YC, 30*XC, 0}, Text,       TEXTID_FileOpenDirLabel, ON, 0, " ", ""},
   {{12*XC, 15.9*YC,  18*XC, 0}, Label,      0,    ON, ALIGN_LEFT, "current dir", ""},
   {{   XC, 3.0*YC, 40*XC, 0}, ListBox,    LISTID_FileOpenExtDirs,  ON, 0, "Directory:", ""},
   {{   XC,  17.3*YC, 10*XC, 0}, ComboBox,   COMBOBOXID_FileListDrivesEx, ON, 0, "Driver", ""},
   {{ 9*XC,   19*YC, 8*XC, 0}, PushButton, PUSHBUTTONID_OK,         ON, 0, "OK", ""},
   {{26*XC,   19*YC, 8*XC, 0}, PushButton, PUSHBUTTONID_Cancel,     ON, 0, "Cancel", ""},
   }
};

Source code (all project) attached.

When you load pbdlg, you can see a dialog as below. But when you operate its directory tree or  driver pulldown item, it will make MicroStation stop working.

Any help are appreciated !

Xue

[V8i - VBA] Origin and Range of SharedCellDefinitionElement

$
0
0

Hi,

I am using an example from LA Solutions to print design files using sheets and/or views. I have modified the code to get the range of the border cell, place a fence and create PDF file.

We have received drawings from a contractor in AutoCAD, and the border cell is a SharedCellDefinitionElement element. I have tried to find the range of the instance of the cell but with no success.

Does anyone have an example of extracting the Range and Origin from a shared cell instance?

Regards

Steve Gard

 

 

 

[V8i MDL] Tips for relative object?

$
0
0

In vba, you can do it with:

Dim element As (tips would pop up)

In C++, is there a way to do it? Such as pop up the MSElement, Dpoint3d etc for you to select so I don't need to remember.......The case sensitive programming would definitely kill me.

Of course, I've tried this one already:

[v8i Macro] Retrieving Text Elements

$
0
0

Hi

Can anyone provide me a code snippet on how to retrieve all the text element in my dgn file?
I am just new in Microstation Programming and I really need help.

Thanks.

RJ

[V8i MDL] Compatibility of .ma

$
0
0

I'm learning MDL as I believe the *.ma would last longer than (or forever) vba and addins. Recently, I saw some post and noticed that some of *.ma not workable for newer version of mstn.

For the best practice, what kind of actions should be done or not done so as to have a *.ma which has the largest compatibility?

In fact, I'm also considering to learn PureMDL so that it should be able to run in an older version. But at the same time, I'm not sure about the future if that *.ma is made by PureMDL.

Is there any API to find whether a model is of type "Drawing" ?

$
0
0

Hello guys!!!

I need to find the type of the model present in my dgn file. I found an API mdlModelRef_getModelType which says whether a model is sheet or normal type.

But how to differentiate between the models of type "Design" and "Drawing" ? 

Is there any API to find whether my model is of type "Drawing"?

Regards,

Rapa

Place a text element based on cell name

$
0
0

Hello everybody,

I am very, very new to Microstation vba and I need to write a small routine that will allow the user to click on a cell in the drawing (cell is part of a reference file) and then to place a note showing the cell name in the active dgn.

I have some knowledge of vba and vb.net but only for Autocad and Excel.

I guess I can select an element and based on the "hilite" property I could get the name but I don't know how to click on an element and get the properties. Can someone point me in the right direction? It will save me a lot of time.

I really appreciate any help and thank you in advance.

e.g.


mdlView_setLevelDisplayMask

$
0
0

Hi all,

I have some code that was working well in V8, but now that we have moved to V8i (08.11.07.443), it's behaviour is a little off. Here is the code:

       for (view_num = 0; view_num < MAX_VIEWS; view_num++)
       {
     if (view_num != view)
     {

      old_levels = mdlView_getLevelDisplayMask(
               ref_model, view_num, VIEW_LEVEL_DISPLAY_TYPE_EFFECTIVE);

      levels = mdlBitMask_clone(old_levels);
            mdlBitMask_setAll(levels, FALSE);
      mdlView_setLevelDisplayMask(ref_model, view_num, levels, TRUE);
      mdlBitMask_free(&levels);
     }
    }

This code used to ensure that the reference file levels were turned off in all views other than the one passed into the function. However, what I am finding in V8i is that if I don't do mdlView_turnOn(view_num); prior to setting the display mask, it doesn't seem to take.

Would this be expected, because needless to say, turning all of the views on to turn the levels off takes significantly longer and doesn't look very good to the user! :)

Any help greatly appreciated!

Mike

building a list from scanned TextNodeElements

$
0
0

What is wrong with my code?

Sub EE_Example()
Dim ee As ElementEnumerator
Dim es As New ElementScanCriteria
Dim elArray() As Element
Dim i As Long
Dim iStart As Long
Dim iEnd As Long
Dim elLevel As Level
Dim elVariant() As Variant
Dim bigString As String

'
' set element scan criteria to find only described elements
'

Set elLevel = ActiveDesignFile.Levels("DRAWING TEXT")

es.ExcludeAllColors
es.IncludeColor 7
es.ExcludeAllLevels
es.IncludeLevel elLevel
es.ExcludeAllTypes
es.IncludeType msdElementTypeTextNode

'
' set enumerator from active model
'
Set ee = ActiveModelReference.Scan(es)

'
' get an element array of all elements found
'
elArray = ee.BuildArrayFromContents
iStart = LBound(elArray)
iEnd = UBound(elArray)

'
' loop through array and get the second line of text
'
For i = iStart To iEnd
elVariant(i) = elArray(i).AsTextNodeElement.TextLine(2)
bigString = Join(elVariant(i), ",")
Next


End Sub

mdlTransient_free() causes MS to crash

$
0
0

Hi all,

    The app I'm updating has transients to display added info. Everything works fine until it comes time to clean things up and free up some memory.  The situation can be paraphrases as:

TransDescrPtransients[100];......Using mdlTransient_addElemDescr(), add stuff to transients......Private void cleanUpStuff(){    for(i=0;i<currentTransient;i++)       {        mdlTransient_returnElemDescr(&tmp,transients[i]);        mdlElmdscr_add(tmp);        mdlElmdscr_freeAll(&tmp);        mdlTransient_free(&(transients[i]),FALSE);    }
}

Jeez, that's painful trying to get that formatted into something readable - any chance of a better editor in here? Anyway, back to the problem. The user generates data, it's fed into transients and then when the function is finished, the data is extracted from the transients, written to file, the elmdesc and transient then freed.

The above function, cleanUpStuff(), when run as is, will crash on the first loop within mdlTransient_free(). If I comment out mdlTransient_free(), the code runs, data is written to file and all is good, until the user changes drawings or terminates the app, then MS crashes. I've also placed mdlTransient_isValid() between mdlElmdscr_freeAll and mdlTransient_free() to check that the transient is correct and it returns true so I'm assuming the transient is good.

Any ideas as to what's going wrong here would be appreciated.

           Andrew

[V8i C++] Toolsettings dialogs display differently on Windows 7 vs. XP

$
0
0

We are migrating our desktops from Windows XP to Windows 7. I am seeing that our MicroStation dialogs dispaly "differently" between the versions of 7 and XP:

 

Windows XP:

 

Windows 7:

 

 

I'm just wondering if this is expected behaviour (smaller, more "washed-out") or is it controlled by video settings somewhere. If this is the expected behaviour, is there a way to make the dialogs seem less "washed-out"?

 

Thanks,

Bruce

[2004 MDL] calculate distance between two points of a line.

$
0
0

I want to calculate the distance of two points of a line, i ve used the mdlVec_distance(point1,point2) function. but i didnt get any message as per i want to display.

is there any function to calculate the distance?

i also heard that while coding the MDL the distance is read in milimeter(mm) whereas in microstation the distance is in meter(m) is it true?

regards

sagar..

[v8i] Applying Rotation and Stacked Fractions to Text Elements

$
0
0

Hi,

I have this as original output below from a third party software.

After applying my VBA code. I have this output

I was able to make it swap (top and bottom dimensions).
But the text element(imperial  unit) are overlapping. How can I also apply the rotation/orientation for those overlapping text?

Also Any idea what class to use to apply stacked fraction?

 

 

vba programing help needed

$
0
0

Hi,

I new to programing and i am stuck on a problem.

What i need to do is extract data from a leader/ note that is associated to a reference file.

The data i need is element id, reference file name, level.

I have looked through the help but can not find anything on extracting the aforementioned data from said note.

Is there anybody out there who has similar problems and over come them or someone that could point me in the right direction.

Much appreciated 

Cheers

Matt


Get text strings from tags associated with an element and place text strings in order in a new text node element

$
0
0
The goal of this routine is to get tag data that is associated to an element 
and then to translate each tag value into a line of text in a new text node
 to be placed once all of the tag data has been collected.
I'm stuck on how to get the tag data.
I wanted to do a second ElementEnumerator to GetSubElements
 from the element with the associated tag data
but I guess they are not considered to be SubElements?
Any ideas?
Sub CellToTextNode()

Dim el                  As Element
Dim elTag               As TagElement
Dim tagNode             As TextNodeElement
Dim point               As Point3d
Dim ee                  As ElementEnumerator
Dim eeTag               As ElementEnumerator
Dim i                   As Long
Dim iStart              As Long
Dim iEnd                As Long
Dim tagValue            As String
Dim elArray()           As Element
Dim bigString           As String


'Get element from user input.

CadInputQueue.SendCommand "CHOOSE NONE"
ShowPrompt "Select element with Tag data."
point = CadInputQueue.GetInput.point
CadInputQueue.SendDataPoint point'Begin ElementEnumerator.

Set ee = ActiveModelReference.GetSelectedElements

'Test to see if the element selected contains Tag data.
    Do While ee.MoveNext
        Set el = ee.Current
        If Not el.HasAnyTags Then
            MsgBox "The element you selected does not have tag data."
            Exit Sub
        Else
           Set eeTag = el.GetSubElements
           elArray = eeTag.BuildArrayFromContents
           iStart = LBound(elArray)
           iEnd = UBound(elArray)
                For i = iStart To iEnd
                    If elArray(i).IsTagElement Then
                    tagValue = CStr(elArray(i).AsTagElement.Value)
                    bigString = bigString & tagValue & ", "
                    End If
                Next
        End If
    Loop

If Len(bigString) > 1 Then
bigString = Left$(bigString, Len(bigString) - 1)
End If


CadInputQueue.SendCommand "CHOOSE NONE"


End Sub

[V8i C# Addin] - How to get a dock panel to size?

$
0
0

I am new to microstation programming and am making an addin. I get everything to work properly but I cannot size the dockpanel. I have a keyin called 'Show' that triggers the showform function below:

internal static void ShowForm(Bentley.MicroStation.AddIn addIn)
{
s_current = null;

s_current = new AreaWindow(addIn);
s_current.AutoSize = false;

s_current.AttachAsTopLevelForm(addIn, true);
s_current.NETDockable = false;

Bentley.Windowing.WindowManager windowManager = Bentley.Windowing.WindowManager.GetForMicroStation();

s_current.m_windowContent = windowManager.DockPanel(s_current, s_current.Name, s_current.Name, Bentley.Windowing.DockLocation.Floating, new Size(350, 0), new Size(0,250));

s_comApp = BMI.Utilities.ComApp;
}

Everything works properly except the dockpanel is not 350 x 250. My form is that size but the dock panel i'm putting it into stretches larger for some reason. and just leaves padding to the right.

I've tried with/without autosize, with/without dockable. Nothing seems to work on it. Any ideas?

[V8i MDL] Creating element, ref: Learning MDL Step by Step [2]

$
0
0

Sometimes, I saw "P" or "CP" added behind of the object. What are they meaning to?

e.g. MSElementP, MSElementCP

And also, assumed that MSElement = MicroStation Element, the what is the full name of MSElementDescr? In vba, creating an element just need declare an element then set it and add to model. But in learning MDL example it needs 3 declarations. Are they necessary? 

Here is a easy reference:

[V8i MDL] HelloWorld fails to start from newer to older

$
0
0

Jan Slegr:

It's always more dangerous to go from newer to older. Post it as a new thread including your codes and errors you receive and I am sure it will be solved.

I've tried to remove those MicroStationAPI code to avoid incompatible problem to V8 2004. But I'm failed and get the error message:

Could not load HELLOWORLD

Unable to load Dynamic Link Module HelloWorld.

OS could not load C:\Program Files\Bentley\Program\MicroStation\mdlapps\HelloWorld.dll, error 14001.

How to understand what the error code "14001" saying?

[V8i, MDL]Extracting text content correctly

$
0
0

Hi All,

I want to extract the panel1 and panel2's size text string as "(31 1/16X 6-9 3/8)" and "(29 7/8X 6-9 3/8)", shown as below. But the actual text string extracted by mdlText_extractString, mdlText_extract or mdlText_extractWide is a strange value. I guess it must be due to the fractions in the string. How to get the correct text string as I expected ?

sample dgn is attached.

Thanks, Xue

Viewing all 383 articles
Browse latest View live


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