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

[v8i SelectSeries 4] Convert to BsplineCurveElement

$
0
0

Hi all,

I'm new to microstation VBA coding and would like everyones input on my problem. My VBA code in Excel does the following


1. Opens and creates a microstation DGN file named "DrawPoints"
2. Iterates through coordinate values in excel sheet and converts them to microstation points 

3. Draws these points using the Bspline Curve "Through points" tool (about 700 points).

It produces the curve in the attached image which is correct for my needs

How can I reference this curve and convert it to a BSplineCurveElement that I can manipulate in VBA?

At the moment, the curve that is generated isn't something I can call upon in my code. I assume I have to scan for the element using ElementScanCriteria but I'm not sure how to select and Dim the element after scanning it.

Thanks for the help in advance!

Sub DrawPoints()

Dim o As MicroStationDGN.Application
Dim oAL As ApplicationObjectConnector
Dim myDGN As DesignFile

'Create DGN File titled "DrawPoints"
Set oAL = New ApplicationObjectConnector
Set o = oAL.Application
o.Visible = True

Set myDGN = o.CreateDesignFile("seed2d", "DrawPoints", True)'Find corresponding coordinates
Dim Coordinate() As Point3d
Dim Ro As Double
Dim StartRo As Double
Dim MaxRo As Double
Dim Xpt As Double
Dim Ypt As Double
Dim point() As Point3d

StartRo = 23
MaxRo = Sheets("Coordinates").Range("A9999").End(xlUp).Row

o.CadInputQueue.SendCommand "PLACE CURVE ICON"
o.SetCExpressionValue "tcb->ms3DToolSettings.curve.type", 2, "3DTOOLS" 'Enables curve through points option

For Ro = StartRo To MaxRo

    Xpt = Sheets("Pantograph").Cells(Ro, 1)
    Ypt = Sheets("Pantograph").Cells(Ro, 2)
    If Xpt + Ypt = 0 Then Exit For

    ReDim Preserve Coordinate(Ro - StartRo)
    Coordinate(Ro - StartRo) = o.Point3dFromXY(Xpt, Ypt)

    point = Coordinate
    o.CadInputQueue.SendDataPoint point(Ro - StartRo), 1

Next Ro

o.CadInputQueue.SendReset

o.CadInputQueue.SendCommand "FIT VIEW EXTENDED 1"

End Sub


[CONNECT U7] Using ElementTemplates

$
0
0

I'm having difficulty reading an Element Template from my .dgnlib. In the .dgnlib I have:

And when I try FindTemplateNodeByPath(), the result is always NULL and Invalid. I'm using the current DGN file as the DgnFileR value - is that incorrect because the template has not been used and is only in the .dgnlib?

		// try to use a template
		XDataTreeOwner* owner = XDataTreeManager::GetDgnXDataTreeOwner(*ISessionMgr::GetActiveDgnFile());
		ElementTemplateNodePtr parentGroup = ElementTemplateUtils::FindTemplateNodeByPath(L"Common Line Types", *ISessionMgr::GetActiveDgnFile());
		wprintf(L"parentGroup.IsNull() %s\n", parentGroup.IsNull() ? L"TRUE" : L"FALSE");
		wprintf(L"parentGroup.IsValid() %s\n", parentGroup.IsValid() ? L"TRUE" : L"FALSE");
		ElementTemplateNodePtr elementTemplate = ElementTemplateUtils::FindTemplateNodeByPath(L"Common Line Types\\Column Line", *ISessionMgr::GetActiveDgnFile());
		wprintf(L"elementTemplate.IsNull() %s\n", elementTemplate.IsNull() ? L"TRUE" : L"FALSE");
		wprintf(L"elementTemplate.IsValid() %s\n", elementTemplate.IsValid() ? L"TRUE" : L"FALSE");

Bruce 

[CONNECT U7] Reading a cell from a cell library

$
0
0

Just wondering if the CONNECT API provides a "newer" method of reading a cell from a cell library. Is mdlCell_getElmDscr() still the preferred way?

Bruce

Merge ShapeElements

$
0
0

Hello All,

I tried to merge Shape Elements by calling Create Region (union) tool for selected shape elements,but microstation hangs at some point. Is there any other option to merge(union) Shape elements?

 Thanks in advance.

Microstation Hanging

$
0
0

Hi,

I have used Microstation V8i select series 2 and visual studio 2005.

Project files are (.cpp, .r, .mke, .mki and .h)

There are two ma files in the directory(ESFD.ma and EFCD.ma)

I have created one Dummy application. when loading dummy application it checks the type(ESFD or EFCD) and calls the .ma file from directory

when loading the dummy application i got the following error. Please find the below image

when clicking retry button it loads the .ma file correctly.

Please find the code for reference:


      sprintf (shree.sqlStatement,"SELECT type FROM input_table where dgnname = '%s'",strupr(dgn_name));
      mdlDB_sqlQuery( tempstr1, shree.sqlStatement);
      if((strcmp (tempstr1, tempstr2) == 0))
      {
  		Unload_Sip_Menu_unload();
		  strcpy(m_DriveUNCPath,"\\project\\mdlapps\\EFCD");	//loading another .ma file
		  CovertParaDrive(m_DriveUNCPath);

	    if(SUC != mdlSystem_getTaskStatistics (NULL, "EFCD"))
		{
			sprintf(m_str,"VS\n\nSERVICE NAME = %s\n\nDATABASE NAME =%s\n\nUSERNAME = %s\n\nCLIENT DRIVE = %s\n\nSERVER DRIVE = %s\n\nTYPE = %s\n\n\n\n",m_ServiceName,m_DatabaseName,m_Username,m_Drive,m_ServerDrive,m_Type);
			mdlDialog_openMessageBox(DIALOGID_LargeInfoBox,m_str,MSGBOX_ICON_INFORMATION);
			mdlSystem_loadMdlProgram (m_DriveUNCPath, NULL, NULL);
			mdlSystem_unloadMdlProgram ("ESFD");
		}
      }
	  else
	  {
		Unload_Sip_Menu_unload();
		strcpy(m_DriveUNCPath,"\\project\\mdlapps\\ESFD");	//loading another .ma file
		CovertParaDrive(m_DriveUNCPath);
		if (SUC != mdlSystem_getTaskStatistics (NULL, "ESFD"))
		{
			sprintf(m_str,"VS\n\nSERVICE NAME = %s\n\nDATABASE NAME =%s\n\nUSERNAME = %s\n\nCLIENT DRIVE = %s\n\nSERVER DRIVE = %s\n\nTYPE = %s\n\n\n\n",m_ServiceName,m_DatabaseName,m_Username,m_Drive,m_ServerDrive,m_Type);
			mdlDialog_openMessageBox(DIALOGID_LargeInfoBox,m_str,MSGBOX_ICON_INFORMATION);
			mdlSystem_loadMdlProgram (m_DriveUNCPath, NULL, NULL);
			mdlSystem_unloadMdlProgram ("EFCD");
		}
	   }

Regards,

Saravanan

KeyinTree for MstnPlatformNet

$
0
0

Hi,

I copy my question that was posted in Developer and Programming forum and paste it here. Any help would be appreciated!

Dear all, 

I am a newbie in MicrostationAPI (using C#). I am following Learning MicroStation Addins Step by Step to create an Addin. It seems MicroStationAPI has changed very much since the post was created. Therefore I got stuck in KeyinTree problem when trying to use commands.xml to structure commands.

In the post, they use parameter KeyinTree in namespace Bentley.Microstation. In the current MicroStationAPI, however, this namespace is replaced with Bentley.MstnPlatformNet (if I understand right, because I could not find Bentley.Microstation), therefore AddInAttribute definition no longer includes KeyinTree.

Could anyone tell me how I can handle this problem?

Thanks in advance.

Inroads and VBA

$
0
0

I'm using MicroStation V8i SelectSeries 4 with inroads. I am trying to automate creating and exporting terrain models. Is there a way to access the Inroads tools and send parameters instead of using the user dialog boxes? So far I have attaching the source data files working fine, but the Inroads tools are always opening the dialog boxes.

Should I be switching to an AddIn instead of using VBA?

[CONNECT U7] Programmatically set active Dimension Style to "none"

$
0
0

If I have an active dimension style (e.g. MyDimStyle) how can I (re)set the active dimension style to "none"? I see that DimenstionStyle::SetActive() needs a DimensionStylePtr, but my attempts to get one for style "none" seems to be failing:

DimensionStylePtr		pNoneDimStyle = DimensionStyle::GetByID(0, *ISessionMgr::GetActiveDgnFile())    // returned !IsValid() && IsNull()
DimensionStylePtr		pNoneDimStyle = DimensionStyle::GetByName(L"", *ISessionMgr::GetActiveDgnFile());    // returned !IsValid() && IsNull()

How does one get a DimensionStylePtr for the style "none"?

THanks

Bruce


Excel VBA help?

$
0
0

This isn't really a MicroStation question, although the table will be linked into a MicroStation sheet. You folks are just the smartest programmers that I know!

I'm trying to write a function that will calculate values and concatenate a string to take decimal feet (xx.xxxx') and convert to feet & inches (xx'-xx x/x")

Function CDecFeet2FtInch(Decimal_Feet, Optional Enter_16_32_64_Etc__To_Round_Inches_To__Fraction_Of_Inch)
    Dim vVal As Variant
    Dim vDenominator As Integer
    Dim iFractInch As Double
    Dim iFeet As Integer
    Dim iInches As Integer'\ First we assign shorter names
    vVal = Decimal_Feet
    vDenominator = Enter_16_32_64_Etc__To_Round_Inches_To__Fraction_Of_Inch'\ Calculate feet
    iFeet = Int(vVal)'\ Calculate whole inches
    iInches = Int((vVal - Int(vVal)) * 12)'\ Now we calculate the number of fractional units in the input value

And.... there I'm stuck. I can't wrap my head around the equation necessary to get the fractional part of the inches leftover from the decimal feet.
as in I can take 32.50' and get 32'-6" but I can't figure out how to take 2.375' and create 2'-4 1/2"

I know this is far more math than programming, but I'm just spinning my wheels and I can't get there from here.
Could somebody help me out?

Thank you.
Mary Bloswick
Visual Basic for Applications 7.1

[CONNECT C#] ElementHandle

$
0
0

I am starting to develop Addins in Microstatin Connect Edition Update6 with C#. I come across many ElementHandle description in the SDK, but still do not know how to create or retrive it. 

While trying to construct an ElementHandle, i was suggested with multiple definition as listed below, which one should I choose?

In the SDK, I also noticed the type ElementHandle* , can anybody tell me how to get this type's instance and its difference with ElementHandle?

[V8i SS4 VBA] Offset text perpendicular to a line

$
0
0

Hello,

I'm writing a macro that will label pipe sizes. The pipes are always lines and always in a 2d file. The view may or may not be rotated.
I can get the pipe labels placed at the midpoint of the pipe at the correct rotation. So far so good...
The problem I'm running into is I'd like to offset the text X number of units perpendicular to the pipe.
What happens if I do this now is that the offset is in the X or Y axis of the file.
I'm looking at rotation matrices and vectors (transform too), but I'm not sure if they are the solution

Any help appreciated,

Thanks

Tom F.

using a mvba command directly in a Key-in command

$
0
0

I found the mvba command for opening the Element Information (CadInputQueue.SendCommand "MDL KEYIN ELEMENTINFO ELEMENT INFO DIALOG")

would like to have key-in do this for me or somehow use the activate it via the vba command like this (vba execute ActiveSettings.CoordinateAccuracy = 6) which works

great. I hope someone out there can help. I have been searching for answer and will continue.

mdlModelRefList_getCount gives unexpected results

$
0
0

I am working with Microstation SS3 and using this code:

fObjP = mdlDgnFileObj_getMasterFile();   
refListP = mdlDgnFileObj_getModelRefList(fObjP);
modelCnt = mdlModelRefList_getCount(refListP);

The results of this always return either 1 or 2. Some files that have 4 models (as shown in the Models dialog in Microstation) only return 2. Some files that have only 1 model return 2. Most files return 1 and correctly match what the Models dialog shows. But I am getting a mismatch for around 10% of my sample files.

Is the mismatch a sign of file corruption? Or is there something I am not understanding about how this function works?

level override colors off

$
0
0

Win 7 V8i, I have searched found the following but do not seem to understand

ActiveDesignFile.levels("Kerb Invert").UsingOverrideColor=False

And make sure you update the design file with:

ActiveDesignFile.RewriteLevels

Same thing with .UsingOverrideLineStyle and .UsingOverrideLineWeight

Remember that you will only see the effects of an override colour if you have 'Level Overrides' on in Microstation. That can also be changed using code (see the .DisplayLevelSymbology property) .

There is a fair bit of help in the Microstation VBA Help file.

I tried using the VBA record feature , did not work after the record.

All I want to do is opent the level Manager go to overide select all and then turn off. I can do it manually but have to do it very oftern when working on changes to older .dgn files and the overrides mess up changes wanted by my boss. He has specific colors and weights and so on The script files I have 

Example: 

lv=7
co=6
lc=0
wt=1
' active symbology bylevel
m,ms Level 7, 0,7,1 Orange

will not work because the overrides block the color, after reading the above I tried more key-in, could not discover with Levels or Levelmanager how to just simply turn off the override color

I looked in some books my great friend Lorys recommended, did not find Level Override when searching the .pdf books. Part of my probllem is failure to ask the question correct when searching. I also looked in the F1 help which had Level symbology and override properties about printing.  Hope this will help someone help me find the answer

different Element classes

$
0
0

Hi,

with the function

Element.GetFromElementRef

I get a

Bentley.DgnPlatformNET.Elements.Element object

then I need to read the XData of the object. Till now i used

element.GetXData1(AppName);

but this functions need a

Bentley.Interop.MicroStationDGN.Element

So my question is, how to come from one the the other? And why there are two differnet Element classes without an esy way to convert.

E.g. a contructor that uses the other class

Greetings

 Markus


Error building CONNECT SDK sample application

$
0
0

Hello guys,

I am getting the following LINK error when attempting to build the CONNECT SDK sample application called steel:

LINK : fatal error LNK1104: cannot open file 'C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\steel.dll'

For some reason the build process fails when attempting to create the DLL file at the specified location. I have checked the access rights to this folder.

I have successfully installed Microsoft Visual Studio 2015 and the CONNECT SDK. 

Here is the output from the bmake command:

C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel>bmake -a steel
Bentley Systems Make Utility. Version 10.00.00.22, May 15 2017
Mon Feb 12 14:07:44 2018

[== Building C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steelcmd.h, (C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel\steelcmd.r) ==]
rcomp @C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.opt
MicroStation Resource Compiler 03.12.02
   Generating header file (C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steelcmd.h) ... done.

[== Building C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steeltyp.r, (C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel\steeltyp.mt) ==]
rsctype @C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\make.opt
MicroStation Type Resource File Generator 03.12.02

[== Building C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steelMultiCompile1.time, (C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel\steel.mke) ==]
**> C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steel.obj <C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel\steel.cpp>
**> C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steelhook.obj <C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel\steelhook.cpp>

cl @C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steelOutOfDateCppSources1.opt
steel.cpp
steelhook.cpp

[== Building "C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\steel.dll", (C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steel.obj) ==]
link -out:"C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\steel.dll"  -WX   -Ignore:4087 -Ignore:4089 -Ignore:4199  -MANIFESTUAC:NO -Release   -debug -incremental:no -fixed:no @C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steellink.rsp
Microsoft (R) Incremental Linker Version 14.00.24215.1
Copyright (C) Microsoft Corporation.  All rights reserved.

-dynamicbase
-dll
"-out:C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\steel.dll""-implib:C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steel.lib""-pdb:C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\steel.pdb"
-fixed:no
C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steel.obj C:\Users\benzi\AppData\Local\Temp\Bentley\MicroStationSDK\objects\steelhook.obj C:\PROGRA~1\Bentley\MICROS~1\library\bentley.lib C:\PROGRA~1\Bentley\MICROS~1\library\BentleyAllocator.lib Advapi32.lib C:\PROGRA~2\WI3CF2~1\10\lib\10.0.16299.0\um\x64\ws2_32.lib C:\PROGRA~1\Bentley\MICROS~1\library\RmgrTools.lib C:\PROGRA~1\Bentley\MICROS~1\library\DgnPlatform.lib gdi32.lib user32.lib kernel32.lib C:\PROGRA~2\MICROS~1.0\VC\lib\amd64\msvcrt.lib
C:\PROGRA~1\Bentley\MICROS~1\library\mdlbltin.lib
LINK : fatal error LNK1104: cannot open file 'C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\steel.dll'
BMAKE: call trace
    line:  404, C:\PROGRA~1\Bentley\MICROS~1\mki\dlmlink.mki
    line:  106, C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel\steel.mke
Mon Feb 12 14:07:48 2018, elapsed time: 0:04

C:\PROGRA~1\Bentley\MICROS~1\examples\Miscellaneous\steel>

I have no idea what is missing here.

Regards,

Benzi Papo

MicroStation v8i MDL SS3 - question about outputting messages to ANYWHERE

$
0
0

I'm trying to drop lines of code into source, just lines to indicate which piece of code is running so I know if I am in the right MC file. I can't seem to get anything to go anywhere (prompts, message centre). 

Tried printf and mdlOutput_MessageCenter, as well as mdlOutput_xxxx. I must be putting it in the wrong place because outputting a message doesn't appear to be rocket science...

Tips or tricks?

Thanks in advance.

Bruce

Cannot Detach a model from a managed model

$
0
0

I've been using MS V8i (SS4) for about a year or more, but just in the last couple weeks I've been suddenly unable to detach any reference files. I get this notice:

I get this pop-up notice.

I've not changed my settings (that I'm aware of). It's not project related. Other users can remove references no problem. It's just from my machine.

So what the heck is a Managed Model, and why is it preventing me from detaching any file (even if I simply attach and detach, it locks in the file).

Most importantly, how do I get it to stop, so I can detach files freely.

FYI, Bentley, messages like this are useless for the user. It should point out the details of the issue, provide a link, etc. Because this is a waste of my time having to hunt for the cause.

Regards,

David

[v8i SelectSeries 4] Creating complex chain around outer coordinates of a shape

$
0
0

Hi all,

I'm looking at creating a complex chain/line element around the most outer edges of the shape I've attached below. My macro is written in excel VBA

What commands should I be looking at to achieve this? I'm having a bit of difficulty because there are so many elements on top of each other and different shape outlines are contributing to different critical points on this outline.

Thanks for the help in advance!

[CONNECT C#] GetFloodBoundary return null

$
0
0

Hi!

It is necessary to construct an element bounded by other elements.
The function is used
GetFloodBoundary.

BCOM.Element[] elms = app.ActiveDesignFile.Fence.GetContents().BuildArrayFromContents();
BCOM.Point3d seedPoint = app.CursorInformation.CurrentPointRaw;
BCOM.Element result = app.GetFloodBoundary(ref elms, null, ref seedPoint, 1, true, -1, BCOM.MsdFillMode.Filled);

This code always returns null.

Where can an error be made?

Viewing all 7260 articles
Browse latest View live


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