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

【CE U13】How to pick facets in the mesh?

$
0
0

Hello,everyone!

I want to select some facets in a mesh(just like the MicroStation tool “Drag mesh”) and other elements around the facets. Then I will deal with the facets with some mesh smoothing algorithms to make the facets smoothing. I named this function partial update mesh

Could anyone tell me what  referenced API should I use?

Thank you~~


Powershell open Microstation via comobject

$
0
0

Hi all,

As the name suggests I am trying to run microstation with PowerShell, with the hope to execute a keyin. It seems to access the object library since intellisense is active:

And it will execute microstation however the file never loads correctly I just get this error:

Does anyone know what might cause this issue? I have multiple installations of microstation (Connect & V8i).

Here is the basic code I have so far:

$ms = new-object -ComObject "MicrostationDGN.Application"
$ms.OpenDesignFile($file, $true)

I did attempt using start-process and can open the file and 'Get-Process'; but interfacing with this process to pass through commands over com server is a challenge I couldn't work out... Any ideas/help would be greatly appreciated!

how to get information element that not written to dgn model?

$
0
0

I'm prgrogramming vba microstation v8.Please, how to get yellow flag symbology element information  on display, when i select element, microstation notifies "No elements found".Thanks.

[CONNECT] [.NET] [Interop] Find out if a Cell is mirrored or not or calculate real angle about Z

$
0
0

How do i find out if a cell is mirrored or not and the real angle of the CellElement.

When i place 2 identical Cells in MicroStation, then mirror one of them (vertical/horizontal doesn't matter), there is no way to tell which one is the mirrored cell (if they are visually mirror symmetric of course).

All the element attributes, position, scale, angle are exactly the same.

If both cells were rotated before, then the only way to tell the mirrored cell, is because element info doesn't show the correct Angle and has it always at 0°

left is normal cell at 8°, right is mirrored cell showing 0° ("analyze element" shows correct -172°)

 

I could ignore the bugged elementinfo interface (the old "analyze element" dialog shows the angle correct),

but really problematic is, that i can't get the real angle about Z from the rotation matrix either.

Does anyone know how i can calculate the real rotation angle from a mirrored cell or get any data if and how a mirror operation was done on a cell?

I'm using the .NET Interop API from Connect.

Data Linkage

$
0
0

How to know the User Data Linkage Index in Microstation version 8?

How to regain focus on AccuDraw after entering values in UserForm

$
0
0

MicroStation Connect (or rather OpenCities Map), VBA

I have a Primitive Command running in Dynamics, and a non-modal dialog.

I would like to reset focus to MicroStation/AccuDraw after entering values in the UserForm.

This was working perfectly in V8i version, using FindWindow and SetForegoundWindow in the Dynamics method.  (Example found in this forum)

In Connect, it seems like I cannot locate the MicroStation window. Any suggestions?

Trim Batch run on CONNECT edition

$
0
0

Hi 

I need to trim my contour files by using batch process on CONNECT edition. It`s work on MicroStation 8 2004 version successfully. But it`s not working on CONNECT edition.I`m using japanese version.

I think my file have BASIC commands.I have no idea to correct with VBA .Can anyone tell me how can i fix this one? 

This is my batch file

Sub main
Dim startPoint As MbePoint
Dim point As MbePoint, point2 As MbePoint
Dim filename As String

Dim newname As String

Dim cSep As String
Dim i As Long
Dim j As Long

cSep= "\"

' コマンドを起動
filename = MbeDgnInfo.dgnFileName

j=0
For i = Len(filename) To 1 Step -1
j=j+1

If Mid$(filename, i, 1) = cSep Then
Exit for
End If
Next

newname=left$(filename,len(filename)-j)&"\poli.txt"

'file Open
Open newname For Input As #1
MbeSendKeyin "active color 207"
MbeSendKeyin "place smartline"
Do Until EOF(1)
Input #1, point.x, point.y, point.z
MbeSendDataPoint point, 1%
Loop

close #1
'file Open
Open newname For Input As #1
Input #1, point.x, point.y, point.z
MbeSendDataPoint point, 1%


MbeSendKeyin "mdl load selectby"
MbeSendKeyin "selectby color off"
MbeSendKeyin "selectby color 207"
MbeSendKeyin "selectby weight off"
MbeSendKeyin "selectby style off"
MbeSendKeyin "selectby level all off"
MbeSendKeyin "selectby level all"
MbeSendKeyin "selectby mode inclusive"
MbeSendKeyin "selectby type all"
MbeSendKeyin "selectby execute"
MbeSendKeyin "CHANGE LOCK"
MbeSendKeyin "mdl unload selectby"


MbeSendKeyin "fit view extended"
MbeSendKeyin "selview 1"
MbeSendKeyin "LOCK FENCE VOID CLIP"
MbeSendKeyin "place fence element"
Input #1, point.x, point.y, point.z
MbeSendDataPoint point, 1%
MbeSendDataPoint point, 1%
MbeSendKeyin "FENCE DELETE"
MbeSendKeyin "SELVIEW 1 "
' 現在のコマンドにリセットを送ります
MbeSendReset

MbeSendKeyin "mdl load selectby"
MbeSendKeyin "selectby color off"
MbeSendKeyin "selectby weight off"
MbeSendKeyin "selectby style off"
MbeSendKeyin "selectby level all off"
MbeSendKeyin "selectby level all"
MbeSendKeyin "selectby mode exclusive"
MbeSendKeyin "selectby type none"
MbeSendKeyin "selectby type text"
MbeSendKeyin "selectby execute"
MbeSendKeyin "CHANGE LOCK"
MbeSendKeyin "mdl unload selectby"

MbeSendKeyin "LOCK FENCE VOID overlap"
MbeSendKeyin "FENCE DELETE"
MbeSendKeyin "SELVIEW 1 "

MbeSendKeyin "choose all"
MbeSendKeyin "CHANGE UNLOCK"

MbeSendKeyin "mdl load selectby"
MbeSendKeyin "selectby color off"
MbeSendKeyin "selectby color 207"
MbeSendKeyin "selectby weight off"
MbeSendKeyin "selectby style off"
MbeSendKeyin "selectby level all off"
MbeSendKeyin "selectby level all"
MbeSendKeyin "selectby mode inclusive"
MbeSendKeyin "selectby type all"
MbeSendKeyin "selectby execute"
MbeSendkeyin "delete element"
MbeSendDataPoint point, 1%
MbeSendKeyin "mdl unload selectby"

MbeSendKeyin "fit view extended"
MbeSendKeyin "selview 1"

MbeSendKeyin "FILEDESIGN"
MbeSendKeyin "save design"

End Sub

Trim Batch run on CONNECT edition

$
0
0

Hi 

I need to trim my contour files by using batch process on CONNECT edition. It`s work on MicroStation 8 2004 version successfully. But it`s not working on CONNECT edition.I`m using japanese version.Can anyone tell me how can i fix this one?

This is my batch file

Sub main
Dim startPoint As MbePoint
Dim point As MbePoint, point2 As MbePoint
Dim filename As String

Dim newname As String

Dim cSep As String
Dim i As Long
Dim j As Long

cSep= "\"

' コマンドを起動
filename = MbeDgnInfo.dgnFileName

j=0
For i = Len(filename) To 1 Step -1
j=j+1

If Mid$(filename, i, 1) = cSep Then
Exit for
End If
Next

newname=left$(filename,len(filename)-j)&"\poli.txt"

'file Open
Open newname For Input As #1
MbeSendKeyin "active color 207"
MbeSendKeyin "place smartline"
Do Until EOF(1)
Input #1, point.x, point.y, point.z
MbeSendDataPoint point, 1%
Loop

close #1
'file Open
Open newname For Input As #1
Input #1, point.x, point.y, point.z
MbeSendDataPoint point, 1%


MbeSendKeyin "mdl load selectby"
MbeSendKeyin "selectby color off"
MbeSendKeyin "selectby color 207"
MbeSendKeyin "selectby weight off"
MbeSendKeyin "selectby style off"
MbeSendKeyin "selectby level all off"
MbeSendKeyin "selectby level all"
MbeSendKeyin "selectby mode inclusive"
MbeSendKeyin "selectby type all"
MbeSendKeyin "selectby execute"
MbeSendKeyin "CHANGE LOCK"
MbeSendKeyin "mdl unload selectby"


MbeSendKeyin "fit view extended"
MbeSendKeyin "selview 1"
MbeSendKeyin "LOCK FENCE VOID CLIP"
MbeSendKeyin "place fence element"
Input #1, point.x, point.y, point.z
MbeSendDataPoint point, 1%
MbeSendDataPoint point, 1%
MbeSendKeyin "FENCE DELETE"
MbeSendKeyin "SELVIEW 1 "
' 現在のコマンドにリセットを送ります
MbeSendReset

MbeSendKeyin "mdl load selectby"
MbeSendKeyin "selectby color off"
MbeSendKeyin "selectby weight off"
MbeSendKeyin "selectby style off"
MbeSendKeyin "selectby level all off"
MbeSendKeyin "selectby level all"
MbeSendKeyin "selectby mode exclusive"
MbeSendKeyin "selectby type none"
MbeSendKeyin "selectby type text"
MbeSendKeyin "selectby execute"
MbeSendKeyin "CHANGE LOCK"
MbeSendKeyin "mdl unload selectby"

MbeSendKeyin "LOCK FENCE VOID overlap"
MbeSendKeyin "FENCE DELETE"
MbeSendKeyin "SELVIEW 1 "

MbeSendKeyin "choose all"
MbeSendKeyin "CHANGE UNLOCK"

MbeSendKeyin "mdl load selectby"
MbeSendKeyin "selectby color off"
MbeSendKeyin "selectby color 207"
MbeSendKeyin "selectby weight off"
MbeSendKeyin "selectby style off"
MbeSendKeyin "selectby level all off"
MbeSendKeyin "selectby level all"
MbeSendKeyin "selectby mode inclusive"
MbeSendKeyin "selectby type all"
MbeSendKeyin "selectby execute"
MbeSendkeyin "delete element"
MbeSendDataPoint point, 1%
MbeSendKeyin "mdl unload selectby"

MbeSendKeyin "fit view extended"
MbeSendKeyin "selview 1"

MbeSendKeyin "FILEDESIGN"
MbeSendKeyin "save design"

End Sub


[CONNECT C#] ElementGraphicsProcessor - ProcessTextString() is never called

$
0
0

Hi, I've been trying to run ElementGraphicsProcessor on text elements and no matter what I try the ProcessTextString() method is never called. Code sample bellow. Running it on a model with a single text element or text node element I get only:

  1. AnnounceIdentityTransform()
  2. AnnounceElementMatSymbology()
  3. AnnounceIdentityTransform()

What should I do to get the ProcessTextString() called?

[OpenCities Map PowerView CONNECT Edition - Verze 10.13.00.48 Windows x64]

DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
ModelElementsCollection allElemsCol = dgnModel.GetElements();
foreach(Element element in allElemsCol)
{
    MyProcessor myProcessor = new MyProcessor();
    ElementGraphicsOutput.Process(element, myProcessor);
}

public class MyProcessor : ElementGraphicsProcessor
{
    public override void AnnounceElementDisplayParameters(ElementDisplayParameters displayParams)
    {
        ShowMessage("AnnounceElementDisplayParameters()");
    }

    public override void AnnounceElementMatSymbology(ElementMatSymbology matSymb)
    {
        ShowMessage("AnnounceElementMatSymbology()");
    }

    public override void AnnounceIdentityTransform()
    {
        ShowMessage("AnnounceIdentityTransform()");
    }

    public override void AnnounceTransform(DTransform3d trans)
    {
        ShowMessage("AnnounceTransform()");
    }

    public override bool ExpandLineStyles()
    {
        ShowMessage("ExpandLineStyles()");
        return true;
    }

    public override bool ExpandPatterns()
    {
        ShowMessage("ExpandPatterns()");
        return true;
    }

    public override FacetOptions GetFacetOptions()
    {
        ShowMessage("GetFacetOptions()");
        return null;
    }

    public override bool ProcessAsBody(bool isCurved)
    {
        ShowMessage("ProcessAsBody()");
        return true;
    }

    public override bool ProcessAsFacets(bool isPolyface)
    {
        ShowMessage("ProcessAsFacets()");
        return true;
    }

    public override BentleyStatus ProcessBody(SolidKernelEntity entity)
    {
        ShowMessage("ProcessBody()");
        return BentleyStatus.Error;
    }

    public override BentleyStatus ProcessCurvePrimitive(CurvePrimitive curve, bool isClosed, bool isFilled)
    {
        ShowMessage("ProcessCurvePrimitive()");
        return BentleyStatus.Error;
    }

    public override BentleyStatus ProcessCurveVector(CurveVector curves, bool isFilled)
    {
        ShowMessage("ProcessCurveVector()");
        return BentleyStatus.Error;
    }

    public override BentleyStatus ProcessFacets(PolyfaceHeader meshData, bool filled)
    {
        ShowMessage("ProcessFacets()");
        return BentleyStatus.Error;
    }

    public override BentleyStatus ProcessSolidPrimitive(SolidPrimitive primitive)
    {
        ShowMessage("ProcessSolidPrimitive()");
        return BentleyStatus.Error;
    }

    public override BentleyStatus ProcessSurface(MSBsplineSurface surface)
    {
        ShowMessage("ProcessSurface()");
        return BentleyStatus.Error;
    }

    public override BentleyStatus ProcessTextString(TextString text, double zDepth)
    {
        ShowMessage("ProcessTextString()");
        return BentleyStatus.Error;
    }

    public override bool WantClipping()
    {
        ShowMessage("WantClipping()");
        return false;
    }

    public void ShowMessage(string brief, string detailed = null, OutputMessagePriority priority = OutputMessagePriority.Debug)
    {
        NotifyMessageDetails messageDetails = new NotifyMessageDetails(
            priority, brief, detailed, NotifyTextAttributes.None, OutputMessageAlert.None);
        NotificationManager.OutputMessage(messageDetails);
    }
}

[MSCE C++] Add a third party VS C++ library to .mke files and build the exist project into MSCE

$
0
0

Hello everybody, has anybody meet this problem that change an existed VS c++ project into .mke file, thus bmake can build all the file together? or add a OpenCV additional library to the .mke file?

dirToSearch = D:/xxx/install/include	#thirdparty libraries
%include cincapnd.mki
---------------------------------------
$(o)$(appName)$(oext)				:$(baseDir)$(appName).cpp			$(baseDir)$(appName).h  $(dirToSearch)/opencv2/core/core.hpp

but this doesn't work, so i wander which step i missed? thanks everybody!!!

[Connect U13] [C# | C++] mdlScanCriteria_setXAttributeTest does not look into Cells

$
0
0

I have a problem with the function mdlScanCriteria_setXAttributeTest mentioned by in this post:
https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/115328/v8i-c-finding-xattribute-data-in-a-model-file/353836#353836

When setting a XAttribute as a Filter, this function does not look into Cells. Same for ParametricCells but there I do not get any Information's no matter if scanning or looking directly into it, but this as a side note. Other Elements are found with that function and when not using mdlScanCriteria_setXAttributeTest I get all Elements inside a Cell (ParametricCells still doesn't work). The same code does work in V8i.

The C# Code:

BCOM.ElementScanCriteria scanCri = new BCOM.ElementScanCriteriaClass();
         scanCri.ExcludeNonGraphical();
         mdlScanCriteria_setReturnType(scanCri.MdlScanCriteriaP(), 1 , 0 /* FALSE */, 2 /* TRUE */);
         XYZmdlScanCriteria_setXAttributeTest(scanCri.MdlScanCriteriaP(), 42 , 42);

         BCOM.ElementEnumerator num = currentModelRef.Scan(scanCri);
         BCOM.Element[] arrElemente = num.BuildArrayFromContents();

XYZmdlScanCriteria_setXAttributeTest is Wrapped and in C++, the XAttributeID gets build. Both 42s are only used for the ID and I've replaced them here.

return mdlScanCriteria_setXAttributeTest(reinterpret_cast<ScanCriteriaP>(p_ScanCriteria), &h_XAttrID, XAttributeHandle::MATCH_ANY_ID, NULL);

mdlScanCriteria_setReturnType(scanCri.MdlScanCriteriaP(), 1 , 0 /* FALSE */, 2 /* TRUE */);
gets used like this in V8i and works there. I do not know why true is a 2 but I've tried 1 also. Removing this line completely doesn't changed anything.
Just getting all Elements with a specific XAttributeID would be faster

[V8i C/C++] Detect GCS

$
0
0

How do I detect whether the active DGN model has a Geographic Coordinate System (GCS) active?

[CONNECT C++] Understanding of CurveLocationDetail

$
0
0

In my DependencyManager code, I'm working with text items dependent on linear elements. I'm seeing a situation that I don't understand. My dependency linkage stores additional data, specifically the distance of the text along the linear element. When the ROOT is changed, the text needs to adjust it's location based on the saved offset in the linkage extra data. Below is the essential code:

double 			distanceUOR;	// the desired distance from the start of the linear element
ElementHandle		ehRoot(pLinkage->root.elemid[0], ACTIVEMODEL);	// Assume ALWAYS will be in current model
CurveVectorPtr		rootCurve = ICurvePathQuery::ElementToCurveVector(ehRoot);
CurveLocationDetail	newPointDetail;
// find the location at 'distanceUOR' from the start of the element
rootCurve->front()->PointAtSignedDistanceFromFraction(0.0, distanceUOR, false, newPointDetail);

double 			calculatedFraction = distanceUOR / rootCurve->Length();	

// why is calculatedFraction not the same as newPointDetail.fraction?

I use PointAtSignedDistanceFromFraction() to determine the "new" location of the text origin after the root has been modified. When I compare the ".fraction" of the CurveLocationDetail that was returned against a calculated fraction (distanceUOR/rootCurve->Length()), they are not the same. Shouldn't they be? Why Not? what does the CurveLocationDetail.fraction really mean?

Bruce

[V8i SS4 C#] Get EC attributes from element

$
0
0

I've done this for Items Types in CE but now I need to go back and do the same thing for V8i and EC for a customer case.

I've looked around and came up with the code below. The problem is that I get a Illegal cast error when calling ReadInstances().

There might be more problems further down so you are welcome to comment on that as well 

(sorry, I just can´t get the code formatting to work!)

public override ElementAttributeList GetAttributesFromElement(BCOM.Element element)

{

ElementAttributeList attributes = null;

if (element == null)

{

  return attributes;

}

try

{

Bentley.ECObjects.Instance.ECInstanceList instances;

instances = XmlInstanceRead.ReadInstances(

  element.MdlElementRef(),

  element.ModelReference.MdlModelRefP());

attributes = new ElementAttributeList();

foreach (Bentley.ECObjects.Instance.ECInstance instance in instances)

{

string className = instance.ClassDefinition.DisplayLabel;

foreach (IECProperty prop in instance)

{

  ElementAttribute attribute = null;

  Bentley.ECObjects.Instance.IECPropertyValue propValue = instance.GetPropertyValue(prop.Name);

  if (propValue == null)

  {

    continue;

  }

  string type = prop.Type.Name.ToLower();

  switch (type)

  {

    case "string":

    if (!propValue.IsNull)

    {

      attribute = new ElementAttribute(prop.DisplayLabel, propValue.StringValue, AttributeType.String);

    }

    break;

[c# COM CONNECT] save settings for file opened with OpenDesignFileForProgram

$
0
0

first this is a stand alone app so I have to use COM.

Maybe im missing something or misunderstanding this but I don't see how to do a save settings on a file that I opened via OpenDesignFileForProgram. I only found the key in but that wont work since its not the active file.

I see the save and saveas methods but I don't see a save settings. I see save settings at the application level. which only affects the active file. isn't save settings saving the design file settings. confused as to why its at the application level and not a method for the file.

Granted most of the things save settings does is GUI related so I see how opendesignfileforprogram wouldn't be the logical to use with save settings. but one of the things save settings does is associate the dgn file with the workspace/workset. which is what im trying to accomplish. since there is no COM call

im trying to get around the fact that DgnWorkSetInfo is not available in COM. and it just takes soo much longer to load the file to the screen (make active).  


C# Connet

$
0
0

In the DgnElementSetTool class of my C# program, I use Bentley.DgnPlatformNET.Elements.Element GetHeadElement() to locate an element.

I tried to cast a Bentley.DgnPlatformNET.Elements.Element of type Line or LineString to a MicroStationDGN.Element and then to a MicroStationDGN.LineElement, is this allowed?  If not, what would be a way to convert it?

The MicroStationDGN.LineElement offers methods that I need in my coding.


if (element.ElementType.Equals(MSElementType.Line) || element.ElementType.Equals(MSElementType.LineString))
{
MicroStationDGN.Element newEl = (MicroStationDGN.Element)element;
MicroStationDGN.LineElement lineElement = newEl.AsLineElement;
double length = lineElement.Length;
MicroStationDGN.Point3d beginPt = lineElement.StartPoint;
MicroStationDGN.Point3d endPt = lineElement.EndPoint;
Array vertices = lineElement.GetVertices();

......

}


Any suggestions/information would be greatly appreciated! I can include the entire DgnElementSetTool class code if needed.

Thank you, Donna

[CONNECT c#] how to get exit code thats returned to the process that started MS_INITAPP

$
0
0

i wrote a MS_INITAPP and then started a process of microstation and used the -WA command line parameter to start it. all that is working but the exit code i get from the process is always zero.

here is how im calling up the process Im doing this from a stand alone app...

Process P = new Process();
P.StartInfo.FileName = MSCexePath;
P.StartInfo.Arguments = "\"-WK" + WorkSpaceName + "\" \"-WW" + projName + "\" -WAOHDOTAssignWorksettoSeed \"-IPATH" + DestinationPath + "\\990-WorkSetStandards\\Seed\\\"";
P.Start();
P.WaitForExit();
int result = P.ExitCode;

and then my MS_INITAPP code  (OHODTAssignWorksettoSeed)

protected override int Run(string[] commandLine)
        {
            try
            {
                if (commandLine.Contains("MS_INITAPPS") || commandLine.Contains("-WA"))
                {
                    string passedWorkSpaceName = "";
                    string passedWorkSetName = "";
                    List<string> filesToProcess = new List<string>();

                    foreach (string curCLP in commandLine)
                    {//get paramaters
                        if (curCLP.ToUpper().StartsWith("-WK"))
                        {
                            passedWorkSpaceName = curCLP.Trim().Remove(0, 3);
                        }
                        if (curCLP.ToUpper().StartsWith("-WW"))
                        {
                            passedWorkSetName = curCLP.Trim().Remove(0, 3);
                        }
                        if (curCLP.ToUpper().StartsWith("-IPATH"))
                        {
                            if (Directory.Exists(curCLP.Trim().Remove(0, 6)))
                            {
                                string tempPath = curCLP.Trim().Remove(0, 6);
                                filesToProcess.AddRange(Directory.GetFiles(tempPath, "*.dgn", SearchOption.AllDirectories).ToList<string>());
                                filesToProcess.AddRange(Directory.GetFiles(tempPath, "*.cel", SearchOption.AllDirectories).ToList<string>());
                                filesToProcess.AddRange(Directory.GetFiles(tempPath, "*.dgnlib", SearchOption.AllDirectories).ToList<string>());
                            }
                        }
                        if (curCLP.ToUpper().StartsWith("-IFILE"))
                        {
                            if (File.Exists(curCLP.Trim().Remove(0, 6)) && (curCLP.ToUpper().EndsWith(".DGN") || curCLP.ToUpper().EndsWith(".CEL") || curCLP.ToUpper().EndsWith(".DGNLIB")))
                            {
                                filesToProcess.Add(curCLP.Trim().Remove(0, 6));
                            }
                        }
                    }
                    if (filesToProcess.Count > 0)
                    {
                        if (passedWorkSetName != "" && passedWorkSpaceName != "")
                        {
                            if (Bentley.MstnPlatformNET.Internal.WorkSpaceManager.ActiveWorkSetName.ToUpper() == passedWorkSetName.ToUpper())
                            {//active workset/workspace match what was passed...means the desired workset was found
                                //must set this to force the creation of the dgnws file if it does not exist
                                Bentley.MstnPlatformNET.Internal.WorkSpaceManager.ActiveWorkSet = Bentley.MstnPlatformNET.Internal.WorkSpaceManager.ActiveWorkSet;
                                //first get template worksetinfo
                                BD.DgnWorkSetInfo SeedWorkSetInfo;
                                string dgnwsFullPath = BD.ConfigurationManager.GetVariable("_USTN_WORKSETDGNWS");
                                BD.DgnFileOwner DGNWSfileowner;
                                BD.DgnFile DGNWSfile = null;
                                BD.DgnDocument DGNWSDoc = BD.DgnDocument.CreateForLocalFile(dgnwsFullPath);
                                DGNWSfileowner = BD.DgnFile.Create(DGNWSDoc, BD.DgnFileOpenMode.ReadOnly);
                                DGNWSfile = DGNWSfileowner.DgnFile;
                                BD.StatusInt openstatus;
                                DGNWSfile.LoadDgnFile(out openstatus);
                                if (openstatus == BD.StatusInt.Success)
                                {
                                    SeedWorkSetInfo = BD.DgnWorkSetInfo.ExtractFromDgnFile(DGNWSfile);
                                    //close file
                                    DGNWSfile.Release();
                                    //loop files to process and assign workset 
                                    int counter = 0;
                                    //now open seed dgn file and apply this worksetinfo to it
                                    foreach (string curdgn in filesToProcess)
                                    {
                                        try
                                        {
                                            BD.DgnFileOwner fileowner;
                                            BD.DgnFile curfile = null;
                                            BD.DgnDocument dgndoc = BD.DgnDocument.CreateForLocalFile(curdgn);
                                            fileowner = BD.DgnFile.Create(dgndoc, BD.DgnFileOpenMode.ReadWrite);
                                            curfile = fileowner.DgnFile;
                                            curfile.LoadDgnFile(out openstatus);
                                            if (openstatus == BD.StatusInt.Success)
                                            {//opened file
                                                SeedWorkSetInfo.Write(curfile);
                                                BD.StatusInt result = curfile.ProcessChanges(BD.DgnSaveReason.FileClose);
                                                if (result == BD.StatusInt.Success)
                                                {//saved file
                                                 //close file
                                                    curfile.Release();
                                                    counter = counter + 1;
                                                }
                                                else
                                                {//failed to save file
                                                 //close file
                                                    curfile.Release();
                                                }
                                            }
                                            else
                                            {//failed to open file
                                            }
                                        }
                                        catch
                                        {//something went wrong processing this file..move on
                                        }
                                    }
                                    Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                                    return counter;
                                }
                                else
                                {//failed to open dgnws file
                                    Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                                    return -5;
                                }
                            }
                            else
                            {//active workset name does not match what was passed..failed to find desired workset
                                Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                                return -4;
                            }
                        }
                        else
                        {//failed to get required command line parameters
                            Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                            return -3;
                        }
                    }
                    else
                    {//no files to process
                        Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                        return 0;
                    }
                }
                else
                {//not run as MS_INITAPPS
                    Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                    return -2;
                }
            }
            catch
            {
                Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp.Quit();
                return -1;
            }
        }

you can see in the code if the process failed it should return a negative number. if the process was successful it should return the number of files it successfully processed. but its always 0. 

anyone else have any luck in this area?

Fit view all (sheets) models for multiple files - using Excel and PowerDraft

$
0
0

I am writing a macro within Microsoft Excel 2016, referencing the Bentley Object Library - using Bentley PowerDraft Select Series 4.

I have used the record macro  feature to identify the key-in commands which achieve the 'fit view' command. When I open any file within microstation the fit view command always works as required (the sheet view is perfrecly centred), however when I run the code I get mixed results - sometimes fit view does not work at all. I've tried to change the commands but with no luck, I cannot understand why it works with key-in but not when called from a macro.

Code is as below.

The UpdateView function is called by another subroutine which loops through all the files.

Sub UpdateView(fileName As String)

Dim oView As View

Dim Counter As Integer
Dim totalFiles As Integer
Dim totalViews As Integer
Dim PctDone As Double

Dim myModelRef As ModelReference

Dim nFile As DesignFile
Dim myDGN As New MicroStationDGN.Application

Counter = 0

Set nFile = myDGN.OpenDesignFile(fileName, False)

  For Each myModelRef In nFile.Models
            'For i = 1 To nFile.Models.Count
                If myModelRef.Type = msdModelTypeSheet Then ' Only scan sheet view of template file
                myModelRef.Activate
                Debug.Print "Updating: " & myModelRef.Name

                myDGN.CadInputQueue.SendCommand "COMPONENTVIEW COMPONENTSETOVERRIDE SUSPEND"
                myDGN.CadInputQueue.SendCommand "FIT VIEW EXTENDED"

                End If
                
                Counter = Counter + 1
  Next myModelRef
            'Next i
myDGN.ActiveDesignFile.Save
myDGN.SaveSettings

nFile.Save
nFile.Close

Set myDGN = Nothing
myDGN.Quit

            
End Sub

[Connect API] PointCloud-Determine number of points inside a box

$
0
0

Hello,

Question about PointCloud.

Is there a way to determine number of points inside a box

without using point selection?

thanks

Nenad

[Connect C++] mdlRefFile_attach changes the directory of the file given in parameters

$
0
0

Hi everybody,

Since the migration on MS Connect Edition, I have a problem with the function mdlRefFile_attach

I want to attach a file which has the same name than the active file but which is in another directory. The attachment works well but the attached file is the same than the active file. The function doesn't attach the file which is in the other directory.

In the function "mdlRefFile_attach ", I check that the correct directory is passed

mdlRefFile_attach(&ModelRefP,gFichierCompare,nom,L"",&origine,&origineref,1.0,NULL,0,NULL, DgnPlatform::REF_FILE_LEVEL_DISPLAY_DEFAULT,true,true);
WChar fileName[MAXFILELENGTH];
mdlModelRef_getFileName(ModelRefP, fileName, sizeof(fileName));

I control the result after the attachement, the file attached is not the good one.

As I said before, this procedure was working well in V8i.

Thanks for your help,

Hervé

Viewing all 4331 articles
Browse latest View live


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