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

[CONNECT C#] how to change a dgn file properties (title, comments)

$
0
0

Trying to figure out how to update a dgnfile's title and comments. I'm talking about the extended file properties. See image below. you get to this by going to the backstage and selecting properties.

this was really easy to do in VBA. it was simply ActiveDesignFile.Title and ActiveDesignfile.Comments.

but trying to use the DGNPlatform NET I cant seem find it.

I have the this so far...been searching the help doc for a while now.

BD.DgnDocument dgndoc = BD.DgnDocument.CreateForLocalFile(fullpath);
BD.DgnFileOwner newfileowner = BD.DgnFile.Create(dgndoc,BD.DgnFileOpenMode.ReadWrite);
BD.DgnFile newfile = newfileowner.DgnFile;
BD.StatusInt openstatus;
newfile.LoadDgnFile(out openstatus);

[CONNECT C#] how do I use a background thread in my addon?

$
0
0

I'm trying to use a background worker in my wpf c# addon app. but I'm getting an System.Access.ViolationException error. on the .net API calls. I know its because its in a new thread. What do I have to do in order to have access to the .net api in a new thread? (note when I move the code back into the UI thread it works fine, so I know the issue is with the thread.)

thanks

JD

[CONNECT C#] change annotation scale of model .net

$
0
0

having trouble figuring out why/how to properly change a model's annotation scale. here is what i have, i dont get any errors. but when i check the file after running this the annotation scale didnt change.

               using BD = Bentley.DgnPlatformNET;
               ...
                BD.DgnDocument dgndoc = BD.DgnDocument.CreateForLocalFile(test);
                BD.DgnFileOwner fileowner = BD.DgnFile.Create(dgndoc, BD.DgnFileOpenMode.ReadWrite);

                BD.DgnFile curfile = fileowner.DgnFile;
                
                BD.StatusInt openstatus;
                curfile.LoadDgnFile(out openstatus);
                bool check1 = curfile.IsLoaded;
                bool check2 = curfile.IsOpen;
                BD.ModelIndexCollection collection = curfile.GetModelIndexCollection();
                IEnumerator<BD.ModelIndex> models = collection.GetEnumerator();
                while (models.MoveNext())
                {
                    BD.StatusInt status;
                    BD.DgnModel model = curfile.LoadRootModelById(out status, models.Current.Id);
                    BD.ModelInfo curInfo = model.GetModelInfo();
                    curInfo.AnnotationScaleFactor = 20;
                }
                curfile.ProcessChanges(BD.DgnSaveReason.FileClose);
                curfile.Release();

i dont know what im doing wrong...

JD

Help get Element attributes information by using MDL functions with MicroStation V7

$
0
0

Help me get Element attributes information by using MDL functions with MicroStation V7.

if  ( mdlAssoc_tagElement (&assocID, 253580, MASTERFILE) == SUCCESS)//(mdlElement_read (&element, MASTERFILE, posFile) == SUCCESS)
		sprintf (message, "ID = %ld\n", assocID);
	   mdlDialog_dmsgsPrint (message);//mdlElement_display (&element, HILITE);

what's the name we should pass in when we want to get the thumbnail from the Model?

$
0
0

Hi experts,

     I have a dgn model and want to get the thumbnail of the model,  with beblow C# code,

            DgnModel model = curSession.GetActiveDgnModel();
            ModelThumbnail thumbNail = model.GetThumbnail("Master");

when i run the code, i pass in the model name for the function GetThumbnail, it returns null,  so my question is what this name should be? where i can get the name list?

thanks,

Rick

   

    

Help with how to read, write text file by using MDL with MicroStation V7

$
0
0

Help me with how to read, write text file by using MDL with MicroStation V7. Because I do not have many of these old programming language documents

Possible to use VS2017 in lieu of VS2015 for Native applications ?

[v8i VBA] Create View Independent TextNode

$
0
0

This question was never truly answered over 5 years ago, so I am asking again.

I can select a text node in the Element Information dialog box and change the text node to View Independent. And then, the entire Text node retains its rotation as the view is rotated. But the code to build a text node specifically prevents one from assigning View Independence to a text node.

If you assign it to each element, then, they rotate about their origins but their origins, being View Dependent, continue to rotate and the result is what I call the Ferris Wheel effect. Like the benches on a Ferris Wheel, the text elements remain upright, but eventually, the upper line of text is below the lower line of text. And the angles in between, often result in the two pieces of text overlapping each other. 

How is one supposed to create an element which is clearly supported by the software, in VB, that does what we need? A true View Independent Multi-line Text Node!    


[CONNECT C++] Determining if an element is Planar

$
0
0

I'm trying to figure out how to determine if a 3D element is planar (specifically, the model contains elements representing contour lines and I want to check each contour to make sure the elevation is consistent) . These elements may be "open" ( e.g. lines, linestrings, arcs,  and complex chains), or they may be "closed" (e.g. shapes, ellipse, complex shapes). For the "open" elements, I'm thinking I can simply check the endpoints if the element is a line, and calculate the normal (somehow) for the other "open" element types. For the "closed" shapes, I would (somehow) calculate the normal as well...

In the past (V8i era), I would try to extract all the vertices into an array and check for consistency in each point's z value. I'm trying to be smarter when re-writing the tool in CONNECT. It seems the CurveVector is way to go, but I'm not sure that is a correct assumption. I'm also not sure of how to get the normal. I'm playing with the functions CentroidNormalArea(), IsPlanar(), and IsPlanarWithDefaultNormal().

Bruce

VBA Project Manager doesn't run

$
0
0

I want to run a macro so I load project with project manager select the macro but there is nothing going on. Why is that? What am I suppose to do?

[msceU7 C++]about dialogbox

$
0
0

Hello, teachers. Ask a question about dynamically loading dialog  item in a dialog box. I checked the previous posts on this topic. The method given is defined in the resource file and then loaded into the program as needed. I want to create items as needed while the program is running and then load them into the dialog box.my english is poor.thanks.

How can I create a macro for placing solid sphere at active point (set by user) at varying co-ordinates?

$
0
0

As shown in the image there are various active points. I want to create a macro to place a solid sphere of diameter entered by user at various co-ordinates which is variable.

I am getting a code like this as shown below in mvba for active points at fixed co-ordinates.

How can I modify this code for active points at variable co-ordinates?

mdlImage_saveViewToRGB always failed?

$
0
0

Hi Expert,

     I  am try to save the view to an bitmap, with below code (I am running with Microstation CE 10.7)

    Bentley::Point2d imageSize;
    imageSize.x = 180;
    imageSize.y = 150;

    byte *imageBuffer = NULL;
    int status = mdlImage_saveViewToRGB(&imageBuffer, &imageSize, (int)MSRenderMode::SolidFill, FALSE, TRUE, 1);
    if (status == SUCCESS && imageBuffer != NULL)
    {

       DgnPlatform::ImageColorMode  colorMode = DgnPlatform::ImageColorMode::RGB;
        status = mdlImage_createFileFromRGB(L"C:\\Tes.jpg", IMAGEFILE_JPEG, colorMode, &imageSize, imageBuffer);

    }

 the api mdlImage_saveViewToRGB always return error, so i am wondering what is the correct parameter for the api? or does it work now?

thanks,

Rick

[CE C#] how to use function CreatePropertyHandler(...)?

$
0
0

Hi.

I have studied 'Itemtype' example on SDK. it's no problem. But , I can not find the function CreatePropertyHandler(Element) that assign property value

How to use the function CreatePropertyHandler(Element) in addin C#?

Thank's

Export Element command not working in microstation using vba

$
0
0

I need to call "Export Element" command using vba code in microstation. But modalHandler has not trigger the "Export Element" command. Please guide me how to call "Export Element" command using vba.

Here I copied my code:

Implements IModalDialogEvents
Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)
End Sub
Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
    If DialogBoxName = "Create Export File" Then
        CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.txt"
        CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd D:\"
        CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd 81.txt"
    '   Remove the following line to let the user close the dialog box.
        DialogResult = msdDialogBoxResultOK
    End If  ' Create Export File
    If DialogBoxName = "Alert" Then
    '   Remove the following line to let the user close the dialog box.
        DialogResult = msdDialogBoxResultOK
    End If  ' Alert
End Sub
Sub Macro1()
    Dim startPoint As Point3d
    Dim point As Point3d, point2 As Point3d
    Dim lngTemp As Long
'   The following statement opens modal dialog "Alert"
    Dim modalHandler As New Macro16ModalHandler
    AddModalDialogEventsHandler modalHandler
'   The following statement opens modal dialog "Create Export File"
'   Start a command
    CadInputQueue.SendCommand "EXPORT ELEMENT "
    RemoveModalDialogEventsHandler modalHandler
    CommandState.StartDefaultCommand
End Sub

[Microstation V8i Select series 3, C++] mdlKISolid_faceToElement API crash

$
0
0

Hi All,

I am trying to use the below MDL API to get the smart model graphic data. I am facing random crash in debug mode while calling mdlKISolid_faceToElement API.

 

If i am trying in release mode, I am not getting the crash but it throws the exception "Access violation reading location 0x00000000" hence not getting the element body from faces. And this is a random behavior each time I am getting exception for different faces.

I have attached the mini dump and exception log, any help on this why I am getting this crash.

communities.bentley.com/.../6445.Dump.zip

Thanks & Regards,

Bhargava

 

[CONNECT U10 MDL] No title in a Dialog-ToolBox - DialogBoxDemo Example

$
0
0

Hi,

actually I'm migrating a V8i-MDL to Connect and had a problem, that my old Dialog Toolbox has an empty title.

I installed

ms10100023en_updt10.exe   and
mssdk10100032en.msi

I was wondering, why this little flaw also is shown in the DialogBoxDemo Example delivered with the SDK?

Now I found the solution, that in my code, as well in the provided example, the title is defined in the wrong place:

It was defined in the DialogBoxRsc structure instead of the DItem_ToolBoxRsc structure, contained by the DialogBox.

This corrected code (part of dlogdemo.r) works for me now:

/*----------------------------------------------------------------------+
|                                                                       |
|   Tool Palette Dialog Box                                             |
|                                                                       |
+----------------------------------------------------------------------*/
DialogBoxRsc DIALOGID_DialogDemoPalette =
    {
    /* Recommended attributes for tool palette frame dialog boxes */
#if defined (MSVERSION) && (MSVERSION >= 0x550)
    DIALOGATTR_TOOLBOXCOMMON,
#else
    DIALOGATTR_DEFAULT | DIALOGATTR_NORIGHTICONS | DIALOGATTR_AUTOOPEN,
#endif
    XC, YC, NOHELP, LHELPCMD, NOHOOK, NOPARENTID, "" /* old: TXT_Frame */,
{
#if defined (MSVERSION) && (MSVERSION >= 0x550)
{{0, 0, 0, 0}, ToolBox, ICONCMDFRAMEID_DialogDemo, ON, 0, "", ""},
#else
{{0, 0, 0, 0}, IconCmdFrame, ICONCMDFRAMEID_DialogDemo, ON, 0, "", ""},
#endif
}
    };

/*----------------------------------------------------------------------+
|                                                                       |
|   Tool Palette Icon Command Frame                                     |
|                                                                       |
+----------------------------------------------------------------------*/
#if defined (MSVERSION) && (MSVERSION >= 0x550)
DItem_ToolBoxRsc ICONCMDFRAMEID_DialogDemo =
    {
    NOHELP, LHELPCMD, NOHOOK, NOARG, 0, TXT_Frame /* old: "" */,
        {
        {{ 0, 0, 0, 0}, IconCmd,    ICONCMDID_DialogDemo1,  ON,  0,  "",  "owner=\"DLOGDEMO\""},
        {{ 0, 0, 0, 0}, ToolBox,    TOOLBOXID_DialogDemo1,  ON,  0,  "",  "owner=\"DLOGDEMO\""},
        {{ 0, 0, 0, 0}, IconCmd,    ICONCMDID_DialogDemo2,  ON,  0,  "",  "owner=\"DLOGDEMO\""},
        {{ 0, 0, 0, 0}, ToolBox,    TOOLBOXID_DialogDemo2,  ON,  0,  "",  "owner=\"DLOGDEMO\""},
        {{ 0, 0, 0, 0}, IconCmd,    ICONCMDID_DialogDemo3,  ON,  0,  "",  "owner=\"DLOGDEMO\""},
        {{ 0, 0, 0, 0}, IconCmd,    ICONCMDID_DialogDemo4,  ON,  0,  "",  "owner=\"DLOGDEMO\""},
        }
    };
#else
DItem_IconCmdFrameRsc ICONCMDFRAMEID_DialogDemo =
    {
    2, 3, NOHELP, LHELPCMD, "",
        {
        {IconCmd,           ICONCMDID_DialogDemo1},
        {IconCmdPalette,    ICONCMDPALETTEID_DialogDemo1},
        {IconCmd,           ICONCMDID_DialogDemo2},
        {IconCmdPalette,    ICONCMDPALETTEID_DialogDemo2},
        {IconCmd,           ICONCMDID_DialogDemo3},
        {IconCmd,           ICONCMDID_DialogDemo4},
        }
    };
#endif

I hope this information is helpful for the community an Bentley too.

Regards,

Tom

Running Tag Report - Macro

$
0
0

Hello,

I am am creating a Tag for every cable on most of our drawings. I can get it to the point where I can create a report and put it into a .CSV/Excel spreadsheet no problem.

Now, i need to do this on almost 100 drawings. So naturally, I find this task to be daunting.

I am wondering if anyone knows of a macro that can do this on it's own. or if they can recommend a way of achieving this without having to physically open each drawing and do this 100 times.

I have no macro knowledge fyi. I work on V8i but i believe I can get connect.

how to avoid starting MDL applications after terminating MircoStation by closing the main window Alt+F4

$
0
0

Hello,

when closing the main window of the MicroStation Connect program, our MDL application gets informed by the unload-function (mdlSystem_setFunction(SYSTEM_UNLOAD_PROGRAM,...) and the exit design file function mdlSystem_setFunction(SYSTEM_EXIT_DESIGN_FILE_STATE,... Now we close all dialogs, terminate the ribbons, free all memory, but after restarting MicroStation Connect our application gets startet by MicroStation automatically. In V8i and all older MicroStation Versions our application was terminated. Perhaps this behaviour is useful for some users - but for our customers ist not sensefull.

Is there a MicroStation variable to avoid starting MDLs automatically after closing MicroStation by closing the window (Alt+F4) ?

Kind regards,

Willi Spiegel

[CE C#] Can I use the IDgnECInstance to get accessor?

$
0
0

HI,

I have add item liberary and item type that include property define on dgn file. That property name on item type include chinese name.

Can I use the IDgnECInstance to get accessor? or How to list all property name?

Because, I can not find property name(chinese name, english name is OK) by IDgnECInstance  always.

I have tried to Encode property name (chinese). But, it can not find still.

Viewing all 4331 articles
Browse latest View live


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