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

Can we consider extents of invisible elements during Fit operation in Micro station V8

$
0
0

In Microstation V8i ,

While Performing FIT operation , Can we consider the extents of the invisible elements and elements present in Layer which is Turn Off . 

If YES , 

Then Please can you provide me the steps to perform for reproducing same scenario as mentioned above.

Are there any KEY-IN available or any settings to take extents of invisible elements in consideration ? 

If YES , 

Then Please provide which KEY-IN to be used and which Settings need to modified .

Thanks&Regards,

Divya .


【C# Microstation V8i】 How to determine if an element is 2D or 3D?

$
0
0

hello:       

         My Microstation version is v8i ss3, my programming language is C#, and Visual Studio version is 2015 Professional, add-in.

As the title says, I want to determine if a Cell contains 3D elements. If it contains, hide this element. Here is my The code, any suggestions are welcome!

public static void Hide3D(string unparsed)
        {
            BCOM.Application app = Utilities.ComApp;
            ElementScanCriteria esc = app.CreateObjectInMicroStation("MicroStationDGN.ElementScanCriteria");
            esc.ExcludeNonGraphical();
            CellElement ele;
            try
            {
                ElementEnumerator oScanEnumerator = app.ActiveModelReference.Scan(esc);
                while (oScanEnumerator.MoveNext())
                {
                    ele = (CellElement)oScanEnumerator.Current;
                        int nestingLevel = 0;
                        ele.Redraw(MsdDrawingMode.Erase);
                        ele.ResetElementEnumeration();
                        while (ele.MoveToNextElement(true, ref nestingLevel))
                        {
                         eleTemp = ele.CopyCurrentElement();
                            if(here need to determine if the element is 2D/3D)
                            {
                                eleTemp.IsHidden = true;
                            }
                            ele.ReplaceCurrentElement(eleTemp);
                        }
                }
            }
            catch (Exception ex)
            {

            }
        }

MSCE C# how to get the Itemtype information form the Parametric Solid Element

$
0
0

How to get the Itemtype information form the Parametric Solid Element  via C# addins?

Thanks.

[V8i] Exiting a Macro if User Cancels Reference Attach Command

$
0
0

We have an update to a standard notes sheet. This needs to be applied to all projects but each project has their own version of this sheet. We determined a macro that attaches the "seed" version to a project's version, fence deletes the existing note and then reference merges the "seed" version into the project version is the most efficient method to implement this update.

The macro works great inside or outside of ProjectWise. But it's not bulletproof. If the user attaches the wrong seed file or cancels before completing the process, the macro still finishes running and the results, while not devastating nor irreversible are less than ideal.

Due to the variety of possible locations where the seed file is located, it is easiest to require the user to browse to its location and manually select it. And due to its single application purpose, anything more complicated than a simple sequencing macro is not justified.

But the programmer in me wants to provide some type of escape mechanism.

The Reference Attach dialog box opens two modal dialog boxes in sequence. However the first one does not seem to activate the ImodalDialogEvent module. It's not until the user finishes browsing to and selecting the file before the code is run.

There seems to be no way to test if they cancel that first dialog box.

I found I could determine if they pick the wrong file or cancel the second dialog box, and exit gracefully.

Is there any way to halt the macro if they cancel the Reference Attach dialog box?

MicroStation MDL二次开发报错

$
0
0

按照Bentley一步步学习MDL教程  第四章MDL应用添加命令 

目前已经对HelloWorld.cpp  四个函数createALine、createAComplexShape、createAProjectedSolid和createABsplineSurface修改如下

/*----------------------------------------------------+
|				HelloWorld.cpp                        |
+-----------------------------------------------------*/

#include <MicroStationAPI.h>
#include <msdialog.fdf>
#include <mselmdsc.fdf>
#include <msbsplin.fdf>
#include "HelloWorldCmd.h"

/*extern "C" DLLEXPORT int MdlMain (int argc,char *argv[])
{
	mdlDialog_dmsgsPrint("Hello World");
	return 0;
}*/

USING_NAMESPACE_BENTLEY_USTN_ELEMENT 
double g_1mu;

void createALine (char *unparsed)
{
   /*MSElement myLine;
   DPoint3d  pts[2];8
   pts[0] = pts[1] = *basePtP;*/
   MSElement myLine;
   DPoint3d  basePt={0,0,0}, pts[2];   pts[0] = pts[1] = basePt;
 
   
   pts[1].x += g_1mu*2;    pts[1].y += g_1mu;
   mdlLine_create (&myLine, NULL, pts);
   EditElemHandle eeh (&myLine, ACTIVEMODEL);
   eeh.AddToModel (ACTIVEMODEL);
}
void createAComplexShape (char *unparsed)
{
   /*MSElement        el;
   MSElementDescrP  edP = NULL;
   DPoint3d         pts[3], tmpPt;
   mdlComplexChain_createHeader (&el, 1, 0);
   mdlElmdscr_new (&edP, NULL, &el);
   pts[0] = pts[1] = pts[2] = *basePtP;*/

   MSElement        el;
   MSElementDescrP  edP = NULL;
   DPoint3d         basePt, pts[3], tmpPt;

   basePt.x = 1.7*g_1mu;   basePt.y = -0.3*g_1mu;    basePt.z = -0.6*g_1mu;
   mdlComplexChain_createHeader (&el, 1, 0);
   mdlElmdscr_new (&edP, NULL, &el);
   pts[0] = pts[1] = pts[2] = basePt;

   pts[1].x += g_1mu*0.3;    pts[1].y += g_1mu*0.7;
   pts[2].x += g_1mu;        pts[2].y += g_1mu;
   mdlArc_createByPoints (&el, NULL, pts);
   mdlElmdscr_appendElement (edP, &el);
   tmpPt = pts[0];         pts[0] = pts[2];     pts[2] = tmpPt;
   pts[1].x = pts[0].x;    pts[1].y = pts[2].y;
   mdlLineString_create (&el, NULL, pts, 3);
   mdlElmdscr_appendElement (edP, &el);
   EditElemHandle eeh (edP, true, false);
   eeh.AddToModel (ACTIVEMODEL);
}
void createAProjectedSolid (char *unparsed)
{
   MSElement        el;
   MSElementDescrP  sectionEdP = NULL, solidEdP = NULL;
   DPoint3d         basePt,pts[6], pt1, pt2;
   basePt.x = 3.2*g_1mu;     basePt.y = -0.6*g_1mu;    basePt.z = -1.2*g_1mu;
   pts[0] = basePt;
   //pts[0] = *basePtP;
   pts[1].x = pts[0].x;             pts[1].y = pts[0].y - g_1mu/2;   pts[1].z = pts[0].z;
   pts[2].x = pts[1].x + g_1mu/2;   pts[2].y = pts[1].y;             pts[2].z = pts[0].z;
   pts[3].x = pts[2].x;             pts[3].y = pts[2].y - g_1mu/2;   pts[3].z = pts[0].z;
   pts[4].x = pts[3].x + g_1mu/2;   pts[4].y = pts[3].y;             pts[4].z = pts[0].z;
   pts[5].x = pts[4].x;             pts[5].y = pts[0].y;             pts[5].z = pts[0].z;
   pt1 = pt2 = pts[0];
   pt2.z += g_1mu;
   mdlShape_create (&el, NULL, pts, 6, 0);
   mdlElmdscr_new (&sectionEdP, NULL, &el);
   mdlSurface_project (&solidEdP, sectionEdP, &pt1, &pt2, NULL);
   mdlElmdscr_freeAll (&sectionEdP);
   solidEdP->el.ehdr.type = SOLID_ELM;
   EditElemHandle eeh (solidEdP, true, false);
   eeh.AddToModel (ACTIVEMODEL);
}
void createABsplineSurface (char *unparsed)
{
   MSElement        el;
   MSElementDescrP  edP = NULL;
   MSBsplineSurface bsSurface;
   MSBsplineCurve   bsCurves[4];
   DPoint3d         basePt, arcPts[4][3];
   basePt.x = 5.4*g_1mu;     basePt.y = -2.3*g_1mu;    basePt.z = -1.8*g_1mu;
   arcPts[0][0] = arcPts[0][1] = arcPts[0][2] = basePt 

   //arcPts[0][0] = arcPts[0][1] = arcPts[0][2] = *basePtP;
   arcPts[0][1].x += g_1mu/2;  arcPts[0][1].z += g_1mu/2;
   arcPts[0][2].x += g_1mu;
   arcPts[1][0] = arcPts[1][1] = arcPts[1][2] = arcPts[0][2];
   arcPts[1][1].y += g_1mu/2;    arcPts[1][1].z += g_1mu/2;
   arcPts[1][2].y += g_1mu;
   arcPts[2][0] = arcPts[2][1] = arcPts[2][2] = arcPts[1][2];
   arcPts[2][1].x -= g_1mu/2;  arcPts[2][1].z += g_1mu/2;
   arcPts[2][2].x -= g_1mu;
   arcPts[3][0] = arcPts[3][1] = arcPts[3][2] = arcPts[2][2];
   arcPts[3][1].y -= g_1mu/2;  arcPts[3][1].z += g_1mu/2;
   arcPts[3][2] = *basePtP;
  
   for (int i=0; i<4; i++)
   {
      mdlArc_createByPoints (&el, NULL, arcPts[i]);
     mdlElmdscr_new (&edP, NULL, &el);
     mdlBspline_convertToCurve (&bsCurves[i], edP);
     mdlElmdscr_freeAll (&edP);
   }
   if (SUCCESS == mdlBspline_coonsPatch (&bsSurface, bsCurves))
   {
      mdlBspline_createSurface (&edP, NULL, &bsSurface);
      EditElemHandle eeh (edP, true, false);
      eeh.AddToModel (ACTIVEMODEL);
      mdlBspline_freeSurface (&bsSurface);
   }
   for (int i=0; i<4; i++)
      mdlBspline_freeCurve (&bsCurves[i]);
}
extern "C" DLLEXPORT int MdlMain (int argc, char *argv[])
{
   g_1mu = mdlModelRef_getUorPerMaster(ACTIVEMODEL);
   /*DPoint3d basePt = {0,0,0};
   createALine (&basePt);
   basePt.x += g_1mu*1.7;     basePt.y -= g_1mu*0.3;    basePt.z -= g_1mu*0.6;
   createAComplexShape (&basePt);
   basePt.x += g_1mu*1.5;     basePt.y -= g_1mu*0.3;    basePt.z -= g_1mu*0.6;
   createAProjectedSolid (&basePt);
   basePt.x += g_1mu*2.2;     basePt.y -= g_1mu*1.7;    basePt.z -= g_1mu*0.6;
   createABsplineSurface (&basePt);
   return 0;*/

    RscFileHandle   rscFileH;
    mdlResource_openFile (&rscFileH, NULL, RSC_READ);
    mdlParse_loadCommandTable (NULL);

    Private MdlCommandNumber  commandNumbers [] =
    {
        {createALine,  CMD_HELLOWORLD_CREATE_LINE},
        {createAComplexShape, CMD_HELLOWORLD_CREATE_COMPLEXSHAPE},
        {createAProjectedSolid, CMD_HELLOWORLD_CREATE_PROJECTEDSOLID},
        {createABsplineSurface,      CMD_HELLOWORLD_CREATE_BSPLINESURFACE},
        0
    }; 
    mdlSystem_registerCommandNumbers (commandNumbers);
    return 0;
}

[CONNECT C++] Level override color

$
0
0

Hi,

I have a simple model with a shape, its color is green and it is on level 1. The level 1's override color is empty.

If the "Level Override" in view attribute is set, the shape is showed as green color.

My question is how to judge level's override color is empty or not? When query color by GetOverrideColor(), it returns 0, which is white color.

LevelHandle level = pDGNFile->GetLevelCacheR().GetLevel(levelId);
if (level->IsValid())
{
    if (bLevelSymbology_Overrides)
        colorCode = level.GetOverrideColor().GetColor();
    else
        colorCode = level.GetByLevelColor().GetColor();
}

[CONNECT C++] How to get referenced Level override color

$
0
0

Hi,

I have a model A with a shape, the shape is in level 1, and level 1's override color is white.

If model B references model A, change level 1's override color to yellow in model B, the shape will show as yellow if "Level Overides" is set in view attribute.

How to get the referenced level override color by API? I tried to query the color of level 1 in model B, the color index returns 0 (white), not 4 (yellow) by my expectation.

LevelHandle level = pDGNFile->GetLevelCacheR().GetLevel(levelId);
if (level->IsValid())
{
    if (bLevelSymbology_Overrides)
        colorCode = level.GetOverrideColor().GetColor();
}

Make direct attachment vba

$
0
0

Currently trying to make nested references direct references.

Not able to keep the level symbology from the container file. eg. level display settings, overrides etc

Cant manage to do this manually either and have been researching for quite sometime.

Would like to be able to make it a macro.

Have the beginning of one below.

Sub mergeNested()
    Dim oModel As ModelReference
    Dim oAtt As Attachment
    Dim oPoint As Point3d
    For Each oModel In ActiveDesignFile.Models
        If oModel.Type = msdModelTypeNormal Then
            oModel.Activate
            For Each oAtt In oModel.Attachments
                If InStr(1, oAtt.AttachName, "NE") <> 0 Then

                    oAtt.NewLevelDisplay = msdNewLevelDisplayAlways
                    oAtt.Rewrite
                    
                    CadInputQueue.SendKeyin "REFERENCE MAKEDIRECT " & oAtt.DesignFile.Name & "->*"
                    CadInputQueue.SendDataPoint oPoint, 1
                    CadInputQueue.SendKeyin "REFERENCE DETACH " & oAtt.DesignFile.Name
                End If
            Next
        End If
    Next
End Sub

Any help would be appreciated.

regards,

Josh


[CONNECT C++] Basis Range vs. Element Range

$
0
0

What's the difference between an element range and a basis range?

DisplayHandler::GetBasisRange()Returns false (and the standard element range) if no basis range/transform is available.

There's also DisplayHandler::SetBasisRange().  I don't understand what that function does.

[CONNECT C++] Windows 2018 Spring Update and ::setlocale (LC_ALL, "")

$
0
0

My app. was working fine until late May 2018, when Windows updated itself to v1803.  When subsequently I built my app., the commands worked but anything involving the UI crashed MicroStation, including any MicroStation commands that popped the UI.

I tracked the problem to a call to ::setlocale (LC_ALL, "") in MdlMain().  Once I removed that call, the app. behaved correctly once more.  ::setlocale (LC_ALL, "") is a C library call to establish a neutral locale.  I think I probably included it to guarantee correct working of regular expressions.  Until Windows v1803 that function has been working OK since the first release of MicroStation CONNECT, and previously with V8i.

I suspect my problem is related to the issues for international apps. and the Windows v1803 update, which seems to have created chaos elsewhere (am I understating the problem?).  Can anyone throw any light on this?   At some point I would like to reinstate ::setlocale (LC_ALL, ""), but don't know how to determine when it would be safe to do so.

mdlDim_getStrings() problems

$
0
0

When a user edit a dimension to add text to the usual "*" this function returns everything as expected. eg ("* min.")

When the user add an additional line (carriage return) into the dimension text   ("* min.\n2 of") the function returns no strings. The \n is the new line.

Is there any was to get the additional strings the user has added.

【MS V8i 】MDL编程如何对有坐标系的链接点 进行精确捕捉定位

[CONNECT C++] ADIM_GETTYPE, ADIM_GETSUB and ADIM_GETSEG macros

$
0
0

There are a couple of functions in the MicroStationAPI whose documentation recommends using the ADIM_GETTYPE, ADIM_GETSUB and ADIM_GETSEG macros.  For example,

MSCORE_EXPORT StatusInt     mdlHitPath_Dimension_getParameters
(
...
UInt32*    partName,  // complete part identifier for part of dimension located, use// ADIM_GETTYPE, ADIM_GETSUB and ADIM_GETSEG to decompose...
);

However, I don't see those macros anywhere in the MicroStationAPI header files.  Is that an omission, or is there a better way to decompose a dimension part identifier?

[MSCE8 C#] mdlSolid_elementFromEdge returns wrong edges

$
0
0

Hi,

did someone try to use mdlSolid_elementFromEdge on MSCE 8?

I get weird results when calling this function on solids having modifiers like taper.

Some lines are correct, others are longer or shorter.

I attach a couple of snapshot to show what I mean.

In the first image I have a solid created by extrusion, and I get correct edges.

In the second image there's a solid with a taper, and the resulting edges.

Is this a known bug?

Correct edges 

Wrong edges

Microstation Macro to Open, Move, and Size dialogs

$
0
0

Hi All, 

I have been investigating if this is possible. And I can't find a way to do this.

Basically I want a macro to:

  • Open Level Manager
  • Move Level Manager to a specific location
  • Resize Level Manager
  • Set Specific views (Ie. Show element priority and plot columns)
  • Set Specific column widths for each setting, and the width of the reference tree.

AND, be able to do this for each dialog.

I want to be able to reset to my default view whenever things get messed up. Like when I disconnect my screens for example.

Is this possible? Thanks.


extracting information from a profile

$
0
0

Hi,

Would there be a small VBA function that could extract information from a profile in a DGN, for example: the slope, the length of the curve, the length of the segment.

Thank you.

老师好:我的imodel sdk 中 没有找到ElementPropertiesGetter 这个类。

$
0
0

请问这个类从哪里可以得到。我现在可以的到属性名称无法得到属性值,有什么方法可以获取对应的属性值。

使用ECClass ::GetProperties(),获取属性名

现在需要得到Element 对应的属性值。

[V8i VBA] Using REFERENCE CLIP BOUNDARY [logical name] from a Fence in a VBA - Results in a Clipping Shape Being Created

$
0
0

If a user has a fence and uses the key-in REFERENCE CLIP BOUNDARY [logical name] the end result is a clipped reference file and the clipping limits are only visible if the user selects the reference file in the reference file dialog box and has one of the highlight modes enabled that includes the boundary.

When we create a VBA macro to do the same thing, the end result is a clipped reference file with a clipping element on the active level.

Both techniques require a data point to accept the clipping limits, but why would the end result be different just because one is live and one is from a VBA macro? 

[CONNECT C++] TextBlock and Annotation Scale

$
0
0

I see that the TextBlockProperties class lets me specify an annotation scale for a TextBlock. How is that different to simply scaling the TextBlock?  Once a TextBlock has annotation scale, does it respond automatically to a change in the DGN model's annotation scale?

Changing text content and element class by batch processing?

$
0
0

Hi,
I try to change a couple of texts an data fields by batch processing and if possible also change the element class for these texts from construction to primary.
Changing text and data fields works well with this batch command:

MDL SILENTLOAD FINDREPLACETEXT,CHNGTXT CHANGE DIALOGTEXT

FIND DIALOG SEARCHSTRING [old text]
FIND DIALOG REPLACESTRING [new text]
CHANGE TEXT ALLFILTERED

but I could not change the class in any way... :(

Is there a possibility to to that?

I tried also to do it by a macro.
The rename part works well again, but not the part for the element class :(

The additional code (red) for the class changing seems not to work

Sub main
Dim startPoint As MbePoint
Dim point As MbePoint, point2 As MbePoint
' Start a command
MbeSendCommand "MDL KEYIN FINDREPLACETEXT,CHNGTXT CHANGE DIALOGTEXT"
' Send a keyin that can be a command string
MbeSendKeyin "FIND DIALOG PAN True"
MbeSendKeyin "FIND DIALOG ZOOM True"
MbeSendKeyin "FIND DIALOG ZOOMLEVEL 14"
MbeSendKeyin "FIND DIALOG SEARCHSTRING "
MbeSendKeyin "FIND DIALOG SEARCHSTRING old Text"
MbeSendKeyin "FIND DIALOG REPLACESTRING new Text"
MbeSendKeyin "CHANGE TEXT ALLFILTERED"

MbeSendKeyin "FIND DIALOG SEARCHSTRING "
MbeSendKeyin "FIND DIALOG SEARCHSTRING new Text"
MbeSendCommand "ACTIVE CLASS PRIMARY "
MbeSendCommand "CHANGE CLASS "

End Sub


I have to change the content and class for 10 textes (always the same) on a lot of drawings.....
perhaps another idea to do that?

Thanks alot
Regards

Viewing all 4331 articles
Browse latest View live


Latest Images

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