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

RE: [V8i MDL C++] Getting a BSIColorDescr from an element colour

$
0
0

This isn't really my area, but it would seem like you could do the following:

    BSIColorDescr* fgColor = nullptr;
    if (SUCCESS == mdlListCell_getIconColorOverrides(pCell, &fgColor, nullptr) && (nullptr != fgColor)) // <- I suspect this probably comes back with nullptr though...
        {
        RgbColorDef rgb;

        rgb.red = 0x7f; rgb.green = 0x7f; rgb.blue = 0;
        mdlColorDescr_setByRgb(fgColor, &rgb, 0);
        }

Use the method below from DgnColorMap to get the element color information...

//! Get the color information from the supplied element color id.
//! @param[out] colorDef IntColorDef for the supplied element color, can be used to get TBGR or RGB color values.
//! @param[out] colorIndex The 0 to INDEX_Background index into the file's DgnColorMap. For rgb and book colors this is the closest match from when they were created.
//! @param[out] isTrueColor True if supplied element color is a rgb or book color, false for color index.
//! @param[out] bookName Color book name for the supplied element color (empty string for rgb and indexed colors).
//! @param[out] colorName Color name from color book for the supplied element color (empty string for rgb and indexed colors).
//! @param[in] elementColor The element color to extract the information for.
//! @param[in] dgnFile The file for the supplied element color.
//! @return SUCCESS if element color is a valid rgb, book, or DgnColorMap index.
//! COLOR_BYLEVEL or COLOR_BYCELL will return ERROR.
static DGNPLATFORM_EXPORT StatusInt ExtractElementColorInfo (IntColorDef* colorDef, UInt32* colorIndex, bool* isTrueColor, WStringP bookName, WStringP colorName, UInt32 elementColor, DgnFileR dgnFile);

Worst case scenario, include these locally (I don't think you'll need to call destroy, the list cell should take care of that).

MSCORE_EXPORT int mdlColorDescr_create (BSIColorDescr **newDescrPP);

MSCORE_EXPORT int mdlColorDescr_destroy (BSIColorDescr **colorDescrPP);

HTH


RE: [V8i] and [CONNECT] mdlFileList_edit OR mdlStringList_getMember bugs with too many files

$
0
0
I have entered a SELECT service request with Bentley support on this issue. Will post the results when they reply

[CONNECT DgnPlatformNet] ScanCriteria.SetElementTypeTest doesn't do what I expect

$
0
0

I'm attempting to scan a DGN model using the DgnPlatformNet.  I'm using the ScanCriteria Class.  When I scan with no filters, everything works and I see all the elements in the DGN model.

When I set an element type filter using SetElementTypeTest  I see problems.  Here's how I'm setting the type mask...

public static ScanCriteria AddElementTypes(this ScanCriteria criteria, params MSElementType[] types)
{
  var bitMask = new BitMask(false);

  foreach (var type in types)
    bitMask.SetBit((uint)type - 1, true);

  StringBuilder s = new StringBuilder();
  s.AppendFormat("AddElementTypes MSElementType {0} bit mask {1}...", types[0], bitMask.ToString (0));
  ElementScanner.ShowMessage(s.ToString());

  criteria.SetElementTypeTest(bitMask);

  return criteria;
}

The message tells you what one would expect: that is, the appropriate bit of the mask is set.  We scan like this...

public UInt32 Scan(MSElementType[] types)
{
    nElements_ = 0;
    ScanCriteria criteria = new ScanCriteria();
    criteria.SetDrawnElements();
    criteria.SetModelRef(model_);
    criteria.AddElementTypes (types);
    criteria.Scan(ElementProcessor);
    return nElements_;
}
public StatusInt ElementProcessor(Element el, DgnModelRef modelRef)
{ ++nElements_; StringBuilder s = new StringBuilder(); s.AppendFormat("Element [{0}] ID {1} type {2}", nElements_, el.ElementId, el.ElementType); ElementScanner.ShowMessage(s.ToString()); return StatusInt.Success; }

This works for elements such as line and shape.  It doesn't work for elements of higher value MSElementType such as Arc, Ellipse or Tag.  What am I doing wrong?

RE: VBA support in the future

$
0
0

[quote user="minion"]my project ended up over 3mb in size[/quote]

During the development cycle VBA inflates itself.  Your project probably is not really 3Mb, but just looks that way.  Since you can't send a VBA project to the gym, try this.

Periodically, when your project attains a state of at least partial stability, compress it.  There is no built-in tool to do this, so you have to do it manually.

  1. Make a temporary copy of your project
    1. For each module, class and UserForm in the project...
    2. Right-click in Project Explorer
    3. Choose the Export option
  2. Put the exported files in a safe place

Now you have a project backup (never a bad thing).  The exported files are now plain text.

Here's the exciting part...

  1. Create a new, empty, VBA project
  2. In Project Explorer...
    1. Right click and choose Import for each previously saved file

Now you have a new .mvba file that should be an identical copy of the original.  It's probably a lot less than 3Mb.  Now you can discard the original, inflated, VBA project and rename the compressed version.

RE: MDL-Programming v8i-Problem: error C3861: "toolSubsystem_fclose" (Asking for Help)

$
0
0

[quote user="Jon Summers"]

If you're building a native-code DLL writting with C++ then use the C++ file API.  There's no need to use the old C-style file I/O provided by MDL.  C++ is simpler to use, more versatile, and doesn't get you tangled up in toolSubsystem_xxx.
[/quote]

Does it mean, that I have to convert the whole MDL including MDL-Dialogs into C++ (that means to create from scratch the Dialogs as MFC-Dialogs), because then ALL must be written in C++?? I thought it would be possible to leave the existing MDL-Dialogs and to renew only the "Logical structure" that was outside from Microstation.

Are there any hints for the Microstation C++ API, which new functions replace old functions from MDL-API ? (Like a table old -> new) ?

Many thanks and best regards,

I. Wieland

RE: How to get the coordinates in sheet and in the original model?

$
0
0
Hello Jan,

Sorry my codes it too many to show here, the following are the brief codes.

sub mycode(Att)
Set oScan = New ElementScanCriteria
Set oEnum = MyAtt.Scan(oScan)
While oEnum.MoveNext
'get point
For Each MyAttachment In MyAtt.Attachments
call mycode(Myattachment)
Wend
Next
end sub

In this way, I get the coordinate of original ref file.


With your sample code, I think I get the coordinate of master file. Thanks a lot!

RE: MDL-Programming v8i-Problem: error C3861: "toolSubsystem_fclose" (Asking for Help)

$
0
0

Hi Ines,

[quote user="Ines Wieland"]Does it mean, that I have to convert the whole MDL...[/quote]

No. In my opinion there are several migration steps and the first one is to convert the code "as is" and to replace only functions not supported anymore. Such code is a candidate to be implemented using C++, but it's not necessary, C code is valid for C++ compiler, so it's more recommendation.

[quote user="Ines Wieland"]...including MDL-Dialogs into C++[/quote]

No. MicroStation resources (dialogs...) are still supported, even in MicroStation CONNECT Edition.

[quote user="Ines Wieland"]Are there any hints for the Microstation C++ API, which new functions replace old functions from MDL-API ? (Like a table old -> new) ?[/quote]

No. In V8i MicroStationAPI is more like extension of existing C MDL API, not the replacement ... there are some exceptions, e.g. MicroStationAPI provides C++ implementation of primitive and modification tools etc., but for the most of operations (e.g. to create an element), C MDL API has to be used.

[quote user="Ines Wieland"]into C++?[/quote]

My feeling is that Jon's advice is not about to move from C MDL API to C++ MicroStationAPI, because it's not the replacement, but to start to use C++ instead of C where possible, so to don't use e.g. char arrays but strings, not fopen but streams etc.

With regards,

  Jan

RE: How to get the coordinates in sheet and in the original model?

$
0
0
Based on my testing I think it's not true. As I wrote, API is implemented in "active model coordinates first", so you always receive an element coordinates how they are in active model (even if the element is in a reference) and you have to calculate the original one. Not opposite direction. And I think my code demonstrates it clearly.

Regards,

Jan

RE: [MVBA]How to get the elements in ref file which shows in the drawing sheet?

$
0
0

Hi  Changsong,

please don't ask several (very different) questions in one post! It violates the forum best practices.

I think you have to implement own test, but it depends on your local conditions and requirements what test is enough. Maybe to test if an element is displayed is enough? In such case use IsDisplayed element property (and check also alterantives IsDisplayedInView and IsEffectivelyDisplayedInView). More precise test can be to create fence and to analyse, what element is inside and what not.

But as I wrote in earlier post, because you don't want to share any example, it's not easy to provide any advice, because "callout" is very general term and the reference can be attached in many different ways.

With regards,

 Jan

RE: How to get the coordinates in sheet and in the original model?

$
0
0
I saw the coordinate in of the scaned element, the coordinate number are very large with must be the original coordinate in the ref file. Then I use .GetReferenceToMasterTransform and Point3dFromTransform3dTimesPoint3d to get the point with coordinate number are very small which is in my sheet border range.

RE: [MVBA]How to get the elements in ref file which shows in the drawing sheet?

$
0
0

Please follow the MicroStation Programming forum best practices.

Identify Your Platform

Please identify the version of MicroStation, or other product such as PowerDraft, that you are using: MicroStation CONNECT or MicroStation V8i. What is the 8-digit version number (e.g. 10.xx.yy.zz) of MicroStation?

If you're using MicroStation in a ProjectWise (PW) managed environment, let us know that too.

The APIs supplied with MicroStation CONNECT are different to those supplied with MicroStation V8i. Consequently, our answers are likely to be different.

Code Syntax Highlighting

When you post code, use the Forum advanced editor's syntax highlighting tool. That's the icon that resembles a pencil:  Syntax Highlighter

DGN Examples

It's often hard to understand a MicroStation problem when it's described in words. 

A picture is worth 1,000 words.  A DGN file is worth ten pictures.  If you help us to understand your problem, we can help you faster & better.

RE: [MVBA]How to get the elements in ref file which shows in the drawing sheet?

$
0
0

[quote user="Jon Summers"]A picture is worth 1,000 words.  A DGN file is worth ten pictures.[/quote]

Unfortunately Changsong don't want to share anything, in other words everything is done to don't receive any answer :-(

Regards,

  Jan

RE: Determine Range of elements in Reference Where Displayed

$
0
0
Thanks for your response Jan.
Some of the points you've mentioned are as I would normally write my code, at this point however the customer has dictated some rules and requirements.

I've been through your version of the code and I really like it, the smaller single purpose functions especially. I will spend some more time reviewing your techniques and try to apply to my version.

More importantly thanks for making the effort and expending your time on a solution dedicated to my problem. It made my day when i saw your reply in my inbox :)

Andy Womsley

RE: [MVBA]How to get the elements in ref file which shows in the drawing sheet?

$
0
0

Sorry~

Please review the attached picture. This is a referenced sheet. As you can see, some elements are in the range, some are outside the range, and some are partially in the range. I'd like to know which elements are in the range. For those partially in, it would be better if I know which parts are in the range.

Thanks a lot!

RE: How to get the coordinates in sheet and in the original model?

$
0
0
Without any example data I don't see any reason to continue with the discussion, because it's time wasting activity.

With regards,

Jan

RE: How to get the coordinates in sheet and in the original model?

$
0
0
Hello All,

My codes are mixed with many other codes, it is not easy to just show the key codes. I would like to show my codes here to get help from you experts. Sorry. I will try to post my codes/pictures as possible in future questions. Thanks a lot!

RE: MDL-Programming v8i-Problem: error C3861: "toolSubsystem_fclose" (Asking for Help)

$
0
0

[quote user="Ines Wieland"]Does it mean, that I have to convert the whole MDL including MDL-Dialogs into C++?[/quote]

No.  My intention was to highlight the folly of attempting to implement an outmoded MDL approach to solving a particular problem when C++ offers something better.  In this case, the toolSubs_api was an evolution of MDL.  Behind the scenes, it provides better file I/O than the orginal MDL but still in a C-style idiom.  When building a C++ project, you have to do some extra work to tell the linker where to find the library (*.lib file) that implements those functions.

To put it another way, you can spend time figuring out how to build using the toolSubs_api, which is a dead end.  Alternatively, you can learn how to use the C++ file I/O API, which gives you a standard, compiler & linker supported, way of writing better code.  Which choice is time better spent?

MDL-Programming v8i-Problem: error C3861: "toolSubsystem_fclose" (Asking for Help)

$
0
0

Hi,

I am trying to convert old MDLs to new Version v8i, but when I compile it with bmake I get error-messages like:

 error C3861: "toolSubsystem_fclose" or

error C3861: "toolSubsystem_fprintf"

In the connected *.CPP-file (where Logical functions outside of Microstation for the MDL are defined) as well as in the <appName>.cpp the directive

#include <stdio.h>

is set.

I read already the thread "error C3861 : 'DrawLineString3d': Identifier not found.   , but the paths are all set, not only in general, but as well explicitely in <appName>.mke-file:


dirToSearch=$(MS)mdl/include/
%include cincapnd.mki

dirToSearch=$(MS)mdl/MicroStationAPI/
%include cincapnd.mki

(and yes, my Path-variable is with ending backslash:  MS=C:\PROGRA~2\Bentley\MICROS~1\MICROS~1\)

I have the Impression, that the Special MDL-include-file $(MS)mdl/include/stdlib/stdio.h is included instead of the 'normal' Version, because only in this file I can find the "toolsubsystem_~" entries, that are nowhere inside the .CPP-file!

Please tell me what is wrong and how to solve this Problem!

Many thanks and best regards,

I. Wieland

RE: How to get the coordinates in sheet and in the original model?

$
0
0
It's not about your code, because you don't ask "what does not work in my code", but about data, because you ask "how to do <something>". Code is helpfull, but not the most important.

To share example dgn file is easy: Take your sheet, leave one or two references, remove the most of elements from them, so the main structure of the attachment will remain, but possibly sensitive data will be not there. How much it will take? 10 minutes at max? A cumulative time that other people will spend reading you question, thinking about it and try to imagine what you try to describe by words only, required and will require ... hundreds of minutes? I think it can be even thousands of minutes. And you are not willing to spend some extra time to prepare as much input data for the discussion? It's sad and you are fighting against yourself, because long term experience shows that people who provide good examples (files, code snippets, screen captures...) receive right answer of advice faster and more often.

With regards,

Jan

How to get the coordinates in sheet and in the original model?

$
0
0

Hello All,

Normally we create a callout in model and attach it in sheet, I 'd like to know the coordinates in sheet and in original model. Any suggestions? Thanks a lot! 

Viewing all 7260 articles
Browse latest View live


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