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

Displaying levels in attachment using OpenDesignForProgramming

$
0
0

HI guys,

I'm sorry if this is a silly question but it has been driving me mad.  I'm sure that I have made a basic mistake, but for the life of me, I cant see what it is. What I am trying to do is create a vba script which runs through a number of subfolders, opens the dgn files in them and displays all levels in a specific reference attachment ("3D-modell") in a specific model ("Drawings").

Dim myFSO As FileSystemObject
Dim myFSORoot As Folder
Dim FSOFolder As Folder
Dim FSOFile As File

Dim oMSAPP As MicroStationDGN.Application
Dim myDGN As DesignFile
Dim newDef As SheetDefinition
Dim oLevel As Level
Dim oAttachment As Attachment

Set myFSO = CreateObject("Scripting.FileSystemObject")
Set oMSAPP = New MicroStationDGN.Application

Set myFSORoot = myFSO.GetFolder(ActiveWorkspace.ConfigurationVariableValue("MS_DESIGNDIR", True))

For Each FSOFolder In myFSORoot.SubFolders

For Each FSOFile In FSOFolder.Files

If Right(FSOFile.Name, 4) = ".dgn" Then

Set myDGN = oMSAPP.OpenDesignFileForProgram(FSOFile.Path, False)

For Each oAttachment In myDGN.Models("Drawing").Attachments

If oAttachment.AttachModelName = "3D-modell" Then

Debug.Print oAttachment.Levels.Count

For Each oLevel In oAttachment.Levels

oLevel.IsDisplayed = True

Next oLevel

End If

Next oAttachment

myDGN.Save

myDGN.Close

End If

Next FSOFile

Next FSOFolder

I know that I am locating the files okay.  I know that I am finding the model I want to operate on okay and that it is even finding the reference but the debug.print line gives me a count of zero levels, thus oLevel is returned as "Nothing" and oLevel.IsDisplayed = True never runs.

Can anyone provide any tips where I am going wrong?

/James


如何把通过mdlMesh_convertToShapes函数打散的若干多边形重新组合为一个网格mesh元素?

$
0
0

本人目前程序中需要将一个mesh打散为shapes后仅取某个区域内的shape重新组合为新的mesh,以达到切割mesh的效果。那应该如何将这些shapes重新组合为网格mesh元素呢?

是否还有更加方便效率的方式实现mesh元素的切割呢?

[V8i C++] Detecting SELECTSeries 3 at run-time

$
0
0

In the past I have delivered my application for 3 main MicroStation versions: V8i, XM and 2004.

Since these need to be compiled separately, I have a different path for each of them that is defined at run-time via a MicroStation configuration file as follows:

%if defined (_VERSION_8_11)
MY_CURRENT_PLATFORM = MicroStation V8i
%elif defined (_VERSION89)
MY_CURRENT_PLATFORM = MicroStation XM
%elif defined (_VERSION80)
MY_CURRENT_PLATFORM = MicroStation 2004
%else
%error "ERROR: Unsupported version of $(_ENGINENAME) platform"
%endif

I then append $(MY_CURRENT_PLATFORM) as a sub-directory of the full location to my binaries pathed to via $(MS_MDLAPPS) to get it to load the correct one.

I have now just noticed a rather unfortunate problem with my product - it no longer loads with SELECTSeries 1 and 2. This is because I am using a couple of functions to handle NET docking that were added in SS3 (version 8.11.09.xx) - specifically mdlWindow_setNETDockable(). I believe this is the first time one major release had SDKs that were not forwards compatible.

I do not want to remove the ability to dock my windows just to support the small number of users stuck on SS2 or earlier, however I also wish to support these users rather than present them with a DLL crash and a mysterious error, particularly since I am still supporting much earlier versions of MS.

So I thought I would just add a new platform to differentiate between SS2 and SS3, however this presents a couple of problems:

  1. It is not possible to have two versions of MicroStation V8i simultaneously installed for testing.
  2. It is not possible to have two versions of the MicroStation  V8i SDK simultaneously loaded for compiling.
  3. I can't find a simple way to conditionally load one set of binaries over another through a pre-defined MicroStation configuration variable.

Is there any way I can handle this without having to have 2 separate installers for SS2 and SS3 support? Currently I have one installer for all MS versions as this makes it easier for my users. Additionally I have many customers where the users have different versions of MS installed and sometimes the IT dept doesn't even know which ones they have.

It would be much more convenient to be able to have both of these products and SDKs loaded separately on the same machine. It would also be much better if Bentley warned us that the V8i SDK has become splintered in a non-compatible way. However, given all this, what is the best way to resolve this problem?

Cheers.

Problems with mdlElement_getID

$
0
0

I have tried a few ways to get this function to work, but it keeps giving me the error cannot convert from 'ElementID' to 'ElementID *'

This is the first way I tried to fix it

	EditElemHandle eh(eleR, dgnModelRef);
	MSElementP eleP = eh.GetElementP();
	ElementID* eleId = eleId = mdlElement_getID(eleP);

Here is the second way

	MSElement el; 
	elementRef_getElement(eleR, &el, elementRef_getElemSize(eleR));
	ElementID* eleId = eleId = mdlElement_getID(&el);

I have tried casting in a few ways to no avail.  I am unsure what is wrong.  Thank you for your help

[CONNECT C++] How to configure Connect MDL?

$
0
0

Hi,

I did some research on this topic on internet and Bentley web site. I did not find information I need.

I got my application compiled and generate my DLL and MA files.I have following questions:

(1) Where should copy these files?

(2) The format of config file looks like?

(3) The Config file should go to which folder?

Are there some document to talk about these?

Best,

Zhen

[v8i ss3 c#] How to "clean" CadInputQueue

$
0
0

Hi,

I am using v8i, w7 and vs2010

this is the code I run by pressing button "Run" on windows form

BCOM.Application m_app = BMI.Utilities.ComApp;
BCOM.CadInputMessage cad_m;

while (m_app.ActiveDesignFile.Fence.IsDefined == false)
{
 CadInputQueue
  cad_m = m_app.CadInputQueue.GetInput(BCOM.MsdCadInputType.DataPoint, BCOM.MsdCadInputType.Reset, BCOM.MsdCadInputType.Command);
  if (cad_m.InputType == BCOM.MsdCadInputType.DataPoint)
  {

  }

}

If, for some reason, this code gets interrupted while running line:  cad_m = m_app.CadInputQueue.GetInput(BCOM.MsdCadInputType.DataPoint, BCOM.MsdCadInputType.Reset, BCOM.MsdCadInputType.Command);

and I try to run this code again by pressing button "Run" I get this error:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in ................

Additional information: Error HRESULT E_FAIL has been returned from a call to a COM component.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Is there some way of cancelig/cleaning last  CadInputQueue before running a new one?

thanks

Manko

C++ Move Element

$
0
0

For the C++ API (V8i) how do you move an entire element, i.e. offset it.   I was thinking this would be easy like in VBA where you .move then supply a point3d.  I was surprised that I didn't find this in the searching I did.

Thank you for your help,

Chad

[V8i VBA] SetActiveDepthByPoint - doesn't work

$
0
0

Hello guys,
I have problem with set Active Depth by Point method in VBA. Below is my SUB

Sub SetActiveDepth(View As Long, ElementId As DLong)

Dim centroid As Point3d
Dim oElement As Element
Dim myClip As ShapeElement
Dim activeView As View
Set oElement = ActiveModelReference.GetElementByID(ClipId)
Set myClip = oElement.AsShapeElement
ActiveModelReference.UnselectAllElements
centroid = myClip.centroid


MsgBox CStr(centroid.X) '' Here Msgbox is showin correct value which is expected by me.
Set activeView = ActiveDesignFile.Views(View)

activeView.SetActiveDepthByPoint centroid

activeView.Redraw


End Sub

Does any one have Idea? Of course Active depth is wokking correctly when I am doing it directly from Microstation.

Thanks,
Marcin


[V8i MDL] Version Information

$
0
0

MDL functions mdlVersion_xxx get a version number and store it in struct VersionNumber or struct VersionNumber16.  Those structs are defined in header file basetypes.h.

Confusingly, header file system.h defines two similar structs: programVersionNumber16 and programVersionNumber.  Why?  Are they ever used?

Carriage Return issues

$
0
0

MicroStation PowerDraft V8i

I am writing a simple keyin script using "@C:\test.txt" in the keyin. The text file has a simple goal of placing text with a carriage return. I thought this would be easy but it is not. I keep hitting road blocks.

The code below gives the yellow text with a yellow fill color. I don't know why or what setting to add to keep the fill 255. The problem only happens if I add "\010". I just tried replacing the text line with a placeholder and doing a find/replace but that cause a different issue .

Can anyone help me fix my code?

TEXTSTYLE ACTIVE "NO SHAPE"
active priority 0
TH=1:80;TW=1:80;WT=1;LV=00 NAP;FT=3;CO=10;ACTIVE TXJ LT;place text; TEST;
xy=2806044:31.6061,6574548:26.3622

TEXTSTYLE ACTIVE ADDRESS
active priority 100
TH=1:80;TW=1:80;LS=1.180334047;WT=1;LV=00 NAP;FT=3;CO=17;ACTIVE TXJ LT;place text;TEXT HERE\010MORE TEXT;
xy=2806044:31.6061,6574548:26.3622

TEXTSTYLE ACTIVE NAP
active priority 0
TH=1:80;TW=1:80;WT=1;LV=00 NAP;FT=3;CO=8;ACTIVE TXJ LT;place text; TEST;
xy=2806043:17.5350,6574545:51.0230

CHOOSE ELEMENT

[CONNECT C++] Cannot create dll file in Visual Studio 2013

$
0
0

I'm using Microstation Connect and I want to create my dll with Visual Studio 2013 directly, not with the .mke file. I have create the .ma file with the .mke file, no problem.

But now I have a problem in the linking. Here are the messages I receive: (Sorry my Visual Studio version is in French)

------ Début de la génération : Projet : mfcdll, Configuration : Debug Win32 ------

 mfcdll.cpp

 hook.cpp

 utils.cpp

d:\utils_cpp\utils.cpp(2024): warning C4018: '<' : incompatibilité signed/unsigned

d:\utils_cpp\utils.cpp(2036): warning C4018: '<' : incompatibilité signed/unsigned

Génération de code en cours...

Création de la bibliothèque D:\MDL_CON\mfcdll\Debug\mfcdll.lib et de l'objet D:\MDL_CON\mfcdll\Debug\mfcdll.exp

utils.obj : error LNK2019: symbole externe non résolu __imp__mdlModelRef_getActive référencé dans la fonction "int __cdecl mdlElement_getLevelStr(char *,union Bentley::DgnPlatform::MSElement *)" (?mdlElement_getLevelStr@@YAHPADPATMSElement@DgnPlatform@Bentley@@@Z)

utils.obj : error LNK2019: symbole externe non résolu __imp__mdlLevel_isValidByName référencé dans la fonction "int __cdecl mdlScanCriteria_addSingleLevelTestStr(char *,struct Bentley::DgnPlatform::ScanCriteria *)" (?mdlScanCriteria_addSingleLevelTestStr@@YAHPADPAUScanCriteria@DgnPlatform@Bentley@@@Z)

mfcdll.obj : error LNK2019: symbole externe non résolu _mdlNativeWindow_initialize référencé dans la fonction "public: __thiscall CmfcdllApp::CmfcdllApp(void)" (??0CmfcdllApp@@QAE@XZ)

mfcdll.obj : error LNK2019: symbole externe non résolu __imp__mdlDialog_publishComplexVariable référencé dans la fonction _MdlMain

mfcdll.obj : error LNK2019: symbole externe non résolu __imp__mdlCExpression_initializeSet référencé dans la fonction _MdlMain

... same messages for all others mdl functions in the project.

D:\MDL_CON\mfcdll\Debug\mfcdll.dll : fatal error LNK1120: 52 externes non résolus

========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

It seems the libraries are not recognize but they are in my project. Here are the command options for the linking in my project:

/OUT:"D:\MDL_CON\mfcdll\Debug\mfcdll.dll" /MANIFEST /NXCOMPAT /PDB:"D:\MDL_CON\mfcdll\Debug\mfcdll.pdb" /DYNAMICBASE "bentley.lib" "mdlbltin.lib" "BentleyGeom.lib" "DgnPlatform.lib" "dgnview.lib" "BentleyAllocator.lib" "RmgrTools.lib" "mstntoolsubs.lib" /DEF:".\mfcdll.def" /IMPLIB:"D:\MDL_CON\mfcdll\Debug\mfcdll.lib" /DEBUG /DLL /MACHINE:X86 /SAFESEH:NO /INCREMENTAL /PGD:"D:\MDL_CON\mfcdll\Debug\mfcdll.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\mfcdll.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /LIBPATH:"C:\Program Files\Bentley\MicroStationCONNECTSDK\library" /TLBID:1 

Somebody sees a bad options?

Regards,

[v8i MDL] Switching off the default lighting option of view

$
0
0

Hi,

How can I switch off default lighting options on View Attributes screen? I can't find it in view flags.

[V8i C++] MstnElementSetTool and use of USES_DRAGSELECT_Line

$
0
0

When using "USES_DRAGSELECT_Line", are the "intersections" (locations where DRAGSELECT_Line cross the selected elements) stored as part of a HItPath? If so, can (and how) those locations be accessed?

Thanks,

Bruce

[V8i VBA] Calculate bearing angle from North to a projected point perpendicular on a target element

$
0
0

Please refer to the image below:

The image shows the following:

  • White Dashed Line = Target element (either complex chain or B-spline)
  • Blue Circles = Elements representing location of cartesian coordinates which I have stored in a CSV file (won't exist in the DGN file).
  • Green Line = Line perpendicular from origin of blue circle perpendicular to white B-spline (won't exist in the DGN file)

Ultimately my end aim is for each coordinate location, calculate the bearing angle measured clockwise from North to the perpendicular projection between origin point and white B-spline as per the red angular dimensions and write this angle back to the next column in my CSV file.

I am confident that I can (for each location) determine the coordinates of the perpendicular intersection however I am unsure on the finals steps afterwards. Is there a way of calculating the angle with only the 2 coordinates or do I need to temporarily create the green line (without adding it to the file) and emulate the use of the measure length tool on the green line (which reports the length and more importantly the direction of the line) or something more elegant?

Not looking for code, just best practice advice to keep the process as simple as possible.

Thanks

[V8i MDL] Why can't I measure the volume of these Elbows?

$
0
0

(Please visit the site to view this file)

The supplied 3D DGN file contains a handful of piping elbows.  They are type 18 elements.  Some are nested in a type 2 cell.  They were probably imported from an unknown third-party plant design tool.

MicroStation's built-in volume measurement tool can't measure the volume of an elbow.  mdlMeasure_volumeProperties fails with an indeterminate error (none of the documented error codes).  It doesn't fail with MDLERR_NONCLOSEDELM, which I would expect if it objected to measuring the volume of a surface.

What's wrong with those elbows?  Should they be converted to a type 19 solid or a SmartSolid to enable a measurement? 


[CONNECT C# Addin] LevelHandle.Name throws Access Violation

$
0
0

I'm using the following code to determine the level name of an element. The code is encountering a System.AccessViolationException when I use the LevelHandle.Name to retrieve the level name. Works fine on some elements, but throws this exception on others. The code doesn't actually catch the exception due to the unmanaged nature of the application throwing the exception (CONNECT) but if I watch the code blow up in the debugger the evaluation of the levelname shows the exception.

///<summary>Gets the level of an Element.</summary>

///<param name="element">The source element from which to retrieve the level name.</param>

///<returns>The level name that the element is on.</returns>

publicstaticstring GetElementLevelName(Element element)

{

// Get Element Property Getter

ElementPropertiesGetter elementPropertiesGetter = newElementPropertiesGetter(element);

// Get DGN Model element belongs to

DgnModel dgnModel = element.DgnModel;

// Get DGN File

DgnFile dgnFile = dgnModel.GetDgnFile();

// Get File Level Cache

FileLevelCache fileLevelCache = dgnFile.GetLevelCache();

// Get Level Id

LevelId levelId = elementPropertiesGetter.Level;

// Get Level Handle

LevelHandle levelHandle = fileLevelCache.GetLevel(levelId, true);

// Return Level Name

string levelName;

try

{

levelName = levelHandle.Name;

}

catch (System.AccessViolationException)

{

levelName = "";

throw;

}

return levelName;

}

I need to create a custom element information category and list of properties.

$
0
0

I have been tasked with creating a method for additional custom information to be added to elements, so that throughout the design process information could be added to objects and modified, such as construction work package information.

I have been able to create a custom EC Schema that I can import to the dgn and then attach the class within the schema to elements and that works fine.

However I am looking for a way to make it more autonomous.  Such as the schema is loaded by imported by default and attached to all existing objects and new objects.  So the user can then just hover and modify info in the flyout or modify info in the Element Information dialog.

My thinking is if it be handled the same as the General Element Information category that shows for every object.   Are the rest of the properties handled with a Schema that can be modified to add additional editable attributes? 

V8i SS3 - Version 08.11.09.578

MDL Loader Error

$
0
0

Hello ,

I've Compiled ManageToolExample.dll from the SDK. But once I try to run it in Microstation Connect I get  Error Message "MDL Loader: Could not load application"

Could someone help me out with a solution. thank you in advance

MDL

$
0
0

Hello,

 I've compiled ManageToolsExample.dll from the SDK example. But when loading it in Microstation Connect I get error message "MDL Loader: Could not load application"

Could anyone help me out . Thank you in advance

[V8i C#] [Element.ReDraw] Possible to draw ontop of all elements?

$
0
0

I have created a primitive command and am trying to draw a transient of the results, however the preview tends to hide below the actual elements due to the elevation it is drawing at.

One idea I had is to calculate the view vector using the view (origin + extents) and the view rotation to calculate a depth very close to where the beginning of the view starts..

Example: 

However, sometimes the transient refuses to display at all as if it is outside of the view extents...  Is there any other approach to doing this? 

Sorry if I have not explained it well, it is difficult to explain :)

Viewing all 4331 articles
Browse latest View live


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