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

[CONNECT VBA] Construct perpendicular to point

$
0
0

How to construct line from one curve to other which is perpendicular to starting point? I have curve1 and curve2 and known point on curve1 from which need to draw perpendicular line to this point from curve2.

ProjectPointOnPerpendicular1 method doesn't give expected result as it draws perpendicular from curve2 not curve1.

ptEndPoint = oBsplineCurveElt2.ProjectPointOnPerpendicular1(ptStartPoint, ptBiasPoint, Matrix3dIdentity)

RE: [CONNECT] Area Measurement

$
0
0

[quote user="Oto"]Text fields doesn't honor MS_MEASURE_AREA_UNIT2 variable so label "sq. m" is shown as "m2" [/quote]

If that's not a programming question, then please ask it in the MicroStation Forum.

What you're referring to is the unit decorator.  The choice is, for example, Sq meters or m2 (when master units are metres).

Another setting relevant to all measurements is accuracy, which determines how many digits appear after the decimal separater (e.g. 1.23 or 1.2345).

[CONNECT] Area Measurement

$
0
0

Using MicroStation CONNECT's Measure Area tool, I can choose to show area in Hectares...

When formatting a text field, I would like to do the same.  I see that Hectares are included in the Units_Schema schema.  However, the MstnPropertyFormatter schema does not include Hectares in its list of Units.

<ECProperty propertyName="Units" ...>
...<StandardValues ...>
...<Value>-1</Value><DisplayString>(Use Active Master Units)</DisplayString><Value>-2</Value><DisplayString>(Use Active Sub Units)</DisplayString><Value>-3</Value><DisplayString>Acres</DisplayString><Value>1050</Value><DisplayString>Miles</DisplayString><Value>1075</Value><DisplayString>Yards</DisplayString><Value>1100</Value><DisplayString>Feet</DisplayString><Value>1125</Value><DisplayString>Inches</DisplayString><Value>1150</Value><DisplayString>Mils</DisplayString><Value>1175</Value><DisplayString>MicroInches</DisplayString><Value>2050</Value><DisplayString>Kilometers</DisplayString><Value>2075</Value><DisplayString>Meters</DisplayString><Value>2100</Value><DisplayString>Centimeters</DisplayString><Value>2125</Value><DisplayString>Millimeters</DisplayString><Value>2150</Value><DisplayString>Micrometers</DisplayString><Value>1049</Value><DisplayString>US Survey Miles</DisplayString><Value>1099</Value><DisplayString>US Survey Feet</DisplayString><Value>1124</Value><DisplayString>US Survey Inches</DisplayString></StandardValues>

Can we request that Hectares be added to that Units list in the MstnPropertyFormatter schema?

Alternatively, is there a way to specify the Hectares conversion from the Units_Schema schema when formatting a text field?

RE: [VBA] ProjectPointOnPerpendicular1 BiasPoint

$
0
0

The bias point was added to allow influencing intersection points for: arcs and ellipses - lines, line strings, and shapes.  The default behavior prior only provided the intersection point at the furthest vector length.  Users requested a way to optionally provide a bias point having less magnitude (distance) than the furthest intersection point yet still a valid intersecting point for that element.  This helps with cases where a shape has multiple intersection points with the intersect vector and you don't want the default furthest segment intersection, but a segment closer in magnitude to the origin of the vector.

Please note ProjectPointOnPerpendicular1 help topic also provides an "Example" hyperlink located at the top of the page providing two code snips that you can use to validate proper operation of the function.  The code sample provides code snips to test against target shape and ellipse elements.

Also, the post: (ProjectPointOnPerpendicular2 - not working as expected ...; may help understand differences between use cases for ProjectPointOnPerpendicular1 and ProjectPointOnPerpendicular2.

HTH,
Bob

RE: [CONNECT C++] App. not unloading - prevents buid

$
0
0
>> The build completes only if I exit MicroStation and restart

Restart MicroStation, or restart your computer?

RE: [CONNECT C++] App. not unloading - prevents buid

$
0
0

[quote user="Paul Connelly"]Restart MicroStation, or restart your computer?[/quote]

Fortunately I don't have an IT department to advise me to reboot the computer on the slimmest pretext.  I should have written: exit MicroStation, complete the build (which is now successful), then restart MicroStation.  Alternitively, exit MicroStation, restart MicroStation, complete the build.

[CONNECT C++] App. not unloading - prevents build

$
0
0

I've recently come across a problem that I've not encountered previously.  During development, it's commonplace to build an app., load into MicroStation, perform some tests, unload the app. and make some changes.

I unload my app. (*.ma + *.dll), make some modification to the source, and rebuild.  The build fails to complete, with this message...

MicroStation Resource Librarian 03.09.02
### Cannot write to output file: G:\PROGRA~1\Bentley\MICROS~2\MICROS~1\mdlapps\xxxx.ma

Note that it's the .ma file that is apparently locked by MicroStation, not the DLL.  I double-check that the app. really is unloaded (in the Utilities|MDL Apps dialog) but have the same problem.  The build completes only if I exit and restart MicroStation.  As you'll appreciate, this is a little tedious — it gives C++ developers the same pain that .NET developers experience.

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

[quote user="Artem bursuk"]LoadRootModelById()[/quote]

I don't see that call in your code snippet.

Each DGN file must be opened before its models are loaded.  How do you open each file?  What options do you choose when opening a V7 DGN file?

Keep in mind that a V7 file is not a model container: the file is the model.  Equally, a V7 DGN file does not have a model ID.


RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

Hi Artem,

[quote user="Artem bursuk"]Hope this is right place to ask my question.[/quote]

Yes, MicroStation Programming community is a main place where application development issues should be discussed.

[quote user="Artem bursuk"]I'm working with...[/quote]

Important information are missing: I recommend to read and follow MicroStation Programming forum best practices and to share information what MicroStation (or other application) version do you use (to specify application build number at the best case) and also what langauge and API.

[quote user="Artem bursuk"]...with DGN Platform public API[/quote]

Wha is DGN Platform public API? Do you mean C++ MicroStationAPI (which includes DgnPlatform library) available in MicroStation CONNECT Edition or something else?

With regards,

  Jan

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

Thank you for quick response,

In case I change LoadModelById() call to LoadRootModelById() I got this very excpetion during this call to LoadRootModelById(). I guess, ReadAndLoadDgnAttachments() is called inside LoadRootModelById().

Here is OpenFile method:

RefCountedPtr<DgnFile> DgnInfoLib::FileHelper::OpenFile(std::wstring path)
{
	DgnOpenStatus status;
	RefCountedPtr<DgnFile> file = nullptr;

	// Create document
	auto document = DgnDocument::CreateFromFileName(status, path.c_str(), nullptr, DEFDGNFILE_ID, DgnDocument::FETCH_Read, DgnDocument::FETCH_OPTION_Default);
	if (document != nullptr)
	{
		// create File and load it's header
		file = DgnFile::Create(*document, DGNFILE_OPENMODE_READONLY, *DgnInfoLib::Utils::StaticHostHelper::host);

		auto ret = file->LoadDgnFile(NULL);
	}

	return file;
}

Thank you in advance,

Artem

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

Hi Jan,

I did read forum best practices, and tried to do my best using guidelines.

Unfortunately, all that I have is DgnPlatform folder consists of docs, libs and dlls. I can share readme.htm with you, but I'm not really sure it helps. https://drive.google.com/open?id=0B6Zfx2wnTZEOREFaZGpUVVVWQkk 

****

I spent few more hours and found out, that in case I call LoadRootModelById() with fillCache=false and all other params as true - I got no exception.

So I read fillCache param description: "If true, calls FillSectionsInModel with DGNMODEL_SECTION_MODEL"

And it's true, I called file->FillSectionsInModel(model, DGNMODEL_SECTION_MODEL) and got the same exception.

After all the problem is API can't fill my filehandler with proper information from disk.

I manipulated with parameters for open method, but it gives no result. Still I'm not done yet :)

Best regards,

Artem

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

Hi Artem,

thanks for providing more details, it's now clearer: In my opinion DgnPlatform is not public development tool as for example MicroStation SDK and it cannot be downloaded by e.g. BDN members from "normal" downloaded pages. I know something like DgnPlatform exists, but I have not seen it and I guess it's on request only.

Consequenlty there will be very little (or even no) experience between other developers with this SDK, so regardless it seems to be similar to MicroStationAPI.

With regards,

  Jan

[DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

Hi all,

Hope this is right place to ask my question.

I'm working with DGN Platform public API to develop tiny DLL, which can be used to get basic meta info about dgn file: version (V7,V8) and references (attachments list).

DLL works perfectly fine with V8 dgn file. Nevertheless, for V7 dgn file during execution method Bentley::DGNPlatform::DgnModelRef::LoadRootModelById() I got an exception:

"Exception thrown at 0x00007FFA85AFD023 (DgnCore2.dll) in Test.exe: 0xC0000005: Access violation writing location 0x00000000000000A0."

Unfortunately, I have no debugging symbols for DgnCore2.dll, so I can't dig deeper and understand the root cause.

Here is code snippet:

	std::vector<std::wstring> references;

	for each (DgnFileBase::ModelIndexCollection::Entry const& entry in file->GetModelIndexCollection())
	{
		Bentley::StatusInt status_load = 0;
		DgnModelPtr model = file->LoadModelById(entry.GetModelId());

		bool loadCaches = false;
		bool loadUndisplayed = false;
		bool loadRasterRefs = false;
		auto type = model->GetModelInfo().GetModelType();
		DgnModelRef::DgnAttachmentLoadOptions refLoadOption(loadCaches, loadUndisplayed, loadRasterRefs);
		model->ReadAndLoadDgnAttachments(refLoadOption);

		if (status_load == 0)
		{
			auto attachs = model->GetDgnAttachmentsP();

			if (attachs)
			{
				for (int i = 0; i < attachs->size(); i++)
				{
					auto attach = attachs->at(i);
					std::wstring attachFullPath(attach->GetAttachFullFileSpec().c_str());
					references.push_back(attachFullPath);
				}
			}
		}
	}

And here is test file which I created in MicroStation V8i ("Save As" option - > select V7 format in the opened window -> click Save):
https://drive.google.com/open?id=0B6Zfx2wnTZEOYnRra2hFamQxMjA

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0
Jan, DgnPlatform is a component of the MicroStation SDK, with a public, documented API. Pretty much any interaction with DgnFiles, models, or elements goes through DgnPlatform, if sometimes indirectly.

Artem, access violation indicates invalid (usually null) pointer. Please confirm there are no such pointers in your own code.
For example, you are missing a check on your DgnModelPtr before accessing it - have you confirmed that LoadModelById() returns non-null?
auto type = model->GetModelInfo().GetModelType();

Regards,
Paul

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

Hi Paul,

[quote user="Paul Connelly"]DgnPlatform is a component of the MicroStation SDK, with a public, documented API.[/quote]

Thanks for more details. I am aware DgnPlatform is one of parts/modules/layers how now MicroStation platform is built. But it was not clear and I guess it's risky to automatically assume that DgnPlatform in MicroStation SDK (as integral part of MicroStation product) is the same as separately installable DgnPlatform SDK ... especially wheather from readme provided by Artem it seems it's older version (because of supported Windows and required Visual Studio) than MicroStation CONNECT Edition SDK.

With regards,

  Jan


RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0
Hi Paul,

Yes, I'm pretty sure none of pointers controlled by me is null.
GetModelType() returns MODEL_TYPE_Normal.

Thanks,
Artem

RE: [DGN Platform public API, C++] "DgnCore2.dll" returns "Access violation" in case gathering attachments information for V7 dgn file

$
0
0

[quote user="Artem bursuk"]I'm pretty sure none of pointers controlled by me is null[/quote]

Ah, the confident cry of the eternal programmer!

That's what ASSERT will confirm for you.

Also, classes that inherit from RefCounted have an .IsValid() member..

file = DgnFile::Create(...);
ASSERT (file.IsValid());

RE: [V8i VBA] Creating Annotation Text in specific units regardless of design file units

$
0
0

Update:

Forget the second part of the question, I've got the text size working using the following code:

Dim oModelRef                                     As ModelReference

    Set oModelRef = ActiveModelReference

    If oModelRef.MasterUnit.Label = "m" Then
        dFontHeight = CDbl(LBox.List(C, 5)) / 1000
        dFontWidth = CDbl(LBox.List(C, 6)) / 1000
    ElseIf oModelRef.MasterUnit.Label = "mm" Then
        dFontHeight = CDbl(LBox.List(C, 5))
        dFontWidth = CDbl(LBox.List(C, 6))
    Else
        MsgBox "Incorrect Designfile Units!"
        Exit Function
    End If

As for the Annotation scale issue, I've been testing the following:

If ActiveSettings.AnnotationScaleEnabled = False Then ActiveSettings.AnnotationScaleEnabled = True'text creation function calls go in here

If ActiveSettings.AnnotationScaleEnabled = True Then ActiveSettings.AnnotationScaleEnabled = False

This appears to work though enabling an active setting seems a crude option even though its been enabled/disabled programmatically. I'd still like to find out how the property handler is used to create annotation text.

 

[V8i VBA] Creating Annotation Text in specific units regardless of design file units

$
0
0

Firstly, I am able to create text elements by providing text width and height values (via text boxes on a form) using the active units of a design file (values are in Metres) however I have been asked to instead for the values to always represent Millimeters AND for the text to be annotation text. In a previous thread I had difficulty with annotation scale not working for newly created cells and Jan Slegr advised that I try using ActiveModelReference.GetLastValidGraphicalElement to apply a property handler after the cell was added to the design file. Without know if creating text receptive to annotation scale changes is a similar in process to creating annotation cells, I have amended my text creation code like so:

Header = Point3dAdd(Point, Point3dFromXYZ(-0.5, -1.25, 0))
            Point = Header

            If CStr(CurrArray(R, C)) = vbNullString Then
                Set oText = CreateTextElement1(Nothing, "0", Point, Matrix3dIdentity)
            Else
                Set oText = CreateTextElement1(Nothing, CStr(CurrArray(R, C)), Point, Matrix3dIdentity)
            End If
            Set WriteChainage = oText
            Set oFont = ActiveDesignFile.Fonts.Find(msdFontTypeWindowsTrueType, sFontName)
            oText.TextStyle.Font = oFont
            oText.TextStyle.Height = dFontHeight
            oText.TextStyle.Width = dFontWidth
            oText.TextStyle.Color = ActiveModelReference.InternalColorFromRGBColor(RGB(sRGBVals(0), sRGBVals(1), sRGBVals(2)))
            oText.TextStyle.Justification = msdTextJustificationRightCenter
            oText.Redraw msdDrawingModeNormal
            ActiveModelReference.AddElement oText

            Set oText = ActiveModelReference.GetLastValidGraphicalElement
            Set oProp = CreatePropertyHandler(oText)
            oProp.SelectByAccessString "AnnotationPurpose"
            If oProp.GetValue = True Then
                oProp.SelectByAccessString "IsAnnotation"
                Debug.Print "the Text Annotation value is " & oProp.GetValue
                oProp.SetValue (True)
            End If

The result can be seen below:

I have checked the VBA help and it doesn't mention AnnotationPurpose anywhere. I discovered the term from this page but I am unsure if it is only specific to annotation cells and not annotation text. Can anyone advise how what I need to change to create annotation text?

Secondly, I am looking for some advice how I can ensure the dFontHeight and dFontWidth variable values always represent Millimeters regardless of if the active designfile units are either Meters or Millimetres. My initial thoughts are to use a simple IF Else statement to check the value of ActiveModelReference.MasterUnit.Label and if the value is m (meters), divide the textbox values by 1000 otherwise just use the textbox value. Does this sound feasible or am I missing something?

RE: [CONNECT C++] App. not unloading - prevents build

$
0
0

Perhaps it is relevant that I created a custom tool palette for my app., using MicroStation's built-in tools...

The customisation includes application commands specified in the key-in.  That key-in mentions the app. [AreaAnnotator].  Could that be the reason that MicroStation is hanging on to the app's .ma file?

Viewing all 7260 articles
Browse latest View live


Latest Images

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