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

[MSCE C#]How to zoom element view?

$
0
0

Hello, I want to center the element in the view according to the element ID.

There is an error in the code above.

I have very little information about it.

Could you help me check where the code is wrong?

I would like to ask you what the problem is. Thank you.

private void ZoomElementView(string Id)
        {
            //get the element range
            DRange3d rangeElem;
            Element hiliteElem = GetElementByString(Id);
            DisplayableElement displayele = hiliteElem as DisplayableElement;
            displayele.CalcElementRange(out rangeElem);

            //
            double rL = rangeElem.High.X - rangeElem.Low.X, rW = rangeElem.High.Y - rangeElem.Low.Y, rH = rangeElem.High.Z - rangeElem.Low.Z;
                   
            //Set the scope of the specified view based on this scope.
            int viewnumber;
            ViewGroupCollection viewcoll = dgnfile.GetViewGroups();
            ViewGroup viewgroup = viewcoll.GetActive();
            viewgroup.FindFirstOpenView(out viewnumber);
            ViewInformation  viewinfo = viewgroup.GetViewInformation(viewnumber);

            //set view parameter
            DPoint3d delta = DPoint3d.FromXYZ(rL,rW,rH);
            DMatrix3d rotmax = viewinfo.Rotation;
        
            //set view range
            viewinfo.SetGeometry(rangeElem.Low,delta,rotmax);
            viewgroup.SetViewInformation(viewinfo, viewnumber);
            viewgroup.SaveChanges();
            viewgroup.SynchViewDisplay(viewnumber, false, true, false);
       
            //update view
            Bentley.MstnPlatformNET.Session.Instance.Keyin("update view extended");          
        }

mdlKISolid_applyTransform is giving an error MDLERR_UnableToTransformBody (-9094).

$
0
0

Hi,

Using mdlKISolid_applyTransform is giving an error MDLERR_UnableToTransformBody (-9094).

When i change the Solid Woking area value the transformation is applied properly. I have changed SWA from 1km to 4.29497km.

How this SWA is defined or is there anyway to calculate the SWA or any API to change the SWA?

What is the maximum SWA can be used?

Thanks,

Akshita.

[V8i C++] How to "walk" the contents of a Complex Chain?

$
0
0

I'm trying to iterate the parts of a Complex Chain using a ChildElemIter, but I can't seem to get past the header...

	void ProcessElemHandle(ElemHandleR	eh)
	{
		printf("ProcessElemHandle()\n");
		printf("Type=%d\n", eh.GetElementType());
		for (ChildElemIter child (eh,EXPOSECHILDREN_Count  ); child.IsValid(); child=child.ToNext())
		{
			ProcessElemHandle(child);
		}
	}


    UInt32          filePos;
    filePos = mdlElement_getFilePos (FILEPOS_CURRENT, &refModelP);
	MSElement			el = {0};
	mdlElement_read(&el, mdlModelRef_getActive(), filePos);
	ElemHandle			eh( &el, mdlModelRef_getActive());

	ProcessElemHandle( eh );

Aren't the "parts" of a Complex Chain considered children?

Bruce

Examples in Microstation Basic

$
0
0

All

Looking for some examples of finding an element in the master file then placing a fence for plotting.

A lot of the old basic programming knowledge(books & examples) is hard to find.

Steven W.

Microstation 08.09.04.88

How to get the dng mesh data used to construct a triange mesh(to a STL file) without any distortion?

$
0
0

Hi experts,

   I am currently try to get the dgn mesh geometry and export to my system, which is to contruct a triangle mesh file(STL, OpenCTM,,,) but when I get the dgn mesh and write it to other file format, I found there will be

distortion, please see below screen shot, i also attach the code how i get the triangles and the dgn mode i used. 

   I am using Microstaion CE Update 7, 10.07.00.39.

this is the original model,

Original ModelOriginal modecommunities.bentley.com/.../V4_2D00_2.dgn

and i use below apis to get the triangle mesh: there is only one mesh(PolyfaceHeaderPtr) within the dgn model,

     pMesh->m_pMesh->Triangulate();  //pMesh->m_pMesh is a PolyfaceHeaderPtr

      auto points = pMesh->m_pMesh->Point();
        auto normals = pMesh->m_pMesh->Normal();
        auto indexs = pMesh->m_pMesh->PointIndex();

        pMesh->m_pointCoordsCount = points.size() * 3;
       pMesh->m_pointCoords = new double[points.size() * 3];

        for (int index = 0; index < points.size(); ++index)
        {
            auto adjustPoint= points[index];
            pMesh->m_pointCoords[index * 3] = adjustPoint.x;
            pMesh->m_pointCoords[index * 3 + 1] = adjustPoint.y;
            pMesh->m_pointCoords[index * 3 + 2] = adjustPoint.z;
        }

        pMesh->m_normalCoords = new double[normals.size() * 3];
        pMesh->m_normalCoordsCount = normals.size() * 3;

        for (int index = 0; index < normals.size(); ++index)
        {
            pMesh->m_normalCoords[index * 3] = (normals[index].x);
            pMesh->m_normalCoords[index * 3 + 1] = (normals[index].y);
            pMesh->m_normalCoords[index * 3 + 2] = (normals[index].z);
        }

        size_t triangleCount = indexs.size() / 4;
        pMesh->m_indexAll = new int[triangleCount * 3];
        int realIndex = 0;
        for (int index = 0; index < indexs.size(); ++index)
        {
            auto pointIndex = indexs[index];
            if (pointIndex == 0) continue;

            if (pointIndex < 0) pointIndex = pointIndex * -1;
            pMesh->m_indexAll[realIndex] = (pointIndex - 1);
            realIndex++;
        }

     I am not sure the index matrix is correct or not, but it works for most models.

   and with above code i am able to get the triangle mesh data which i can save to a STL file, but the STL geometry seems lost some triangles at the edge which lead to the distortion.

the result stl mesh looks as below,

STL model view in Microstationcommunities.bentley.com/.../STL-mesh-no-pt-offset-_2B00_-normal-0-0-1.dgn

we can see the distortion on the edge, how we can remedy this distortion?

and I also try to export the dgn mesh to a stl file in Microstaion(with export command), and then import the stl file into a new dgn file,

exported stl file by microstation Export commandcommunities.bentley.com/.../export-from-Microstation.dgn

and the distortion is much worse.

so is there any way to fix this distortions when i want to get the triangle mesh from a dgn mesh?

[CONNECT C++] How to get rid of Defunct References

$
0
0

This is an old archived thread that I just found useful so I thought I would revive it with updated CONNECT code:

ModelRefIteratorP iterator = NULL;
mdlModelRefIterator_create(&iterator, mdlModelRef_getActive(), MRITERATE_PrimaryChildRefs, 0);
DgnModelRefP refmodelRefP = mdlModelRefIterator_getFirst(iterator);
while (NULL != refmodelRefP)
    {
        bool fnf = FALSE;

    mdlRefFile_getBooleanParameters(&fnf, REFERENCE_FILENOTFOUND, refmodelRefP);
    if (fnf)
        mdlRefFile_detach(refmodelRefP);
    refmodelRefP = mdlModelRefIterator_getNext(iterator);
    }

Kudos to Jon Summers for supplying the initial answer 9 years ago!

Original post https://communities.bentley.com/products/programming/microstation_programming/f/archived-microstation-v8i-programming-forum/53466/how-to-getrid-of-defunct-references/124272#124272

[V8i C++] CurveQuery::GetLength()

$
0
0

I've got a line placed in a 3D model (Top View) that is 1000 ft long. I'm trying to use CurveQuery::GetLength() to return the length of the line. The value returned, when converted to feet, does not match the "length" as shown in the Element Information dialog. I suspect the issue may be the 3rd parameter - the Transform. I'm not sure what to put there, so I'm using NULL.

	ElemHandle			pickedElemHandle( pickedEdP, true, true);	// note use of true here-special case for V8i when reading existing element
																	// into ElementDescr and creating ElemHandle
    // check ElemHandle - make sure it's valid
	printf("IsValid() %d,  IsPersistent() %d\n", pickedElemHandle.IsValid(), pickedElemHandle.IsPersistent());
	double					length;
	CurveQuery::GetLength( pickedElemHandle, length, NULL);
    // Return value different than result provided by "Element Information"

Bruce

[V8i C++] How to Project the Cursor Location to the Nearest Point on a Complex Shape or String

$
0
0

I've got a need to project the cursor to the nearest point on a complex element. Using mdlProject_perpendicular() returns a -105 (BadElement) when supplying the complex element's MSElementDescr. I thought that maybe I could use the CurveQuery class, but I've not been able to get anything to work using that class. Am I looking in the wrong place to do what I'm trying to accomplish?

Bruce


In microstation Connect version, what is easy way to drop text from cells in vba coding through all of the dgn file with multiple models?

$
0
0

I need to change the textstyle of the text inside the cells.

How to get the selected Workflow from Ribbon from code

$
0
0

I am using MicroStation Connect, Update 9, version 10.09.01.01.

I have been looking if it is possible to get the selected Workflow (from ribbon).

The user selects a workflow from ribbon, and, in code (C#), I would like to get the selected workflow.

The name of the workflow would be enough.

So far I did not succeeded in finding a solution.

I do not see a variable in which the selected workflowname from ribbon.

In the Object Browser  (Visual Studio) there are some classes who might doing some with the Active Workflow ( ribbonview.dll, ribbonviewapp, public string ActiveWorkflow { get; }),

but do not get it working.

Does anyone know if this is possible and if so, how?

Every help is appreciated!

From code, there are some classes 

[CONNECT C++] Get Text Style from TextBlock

$
0
0

How do I get the text style from a TextBlock?

I want to create a new TextBlock using the text style from an existing TextBlock.  I can see methods to apply a style to a TextBlock, but nothing to get a style.  I looked at ITextQuery and ITextEdit, but neither do those classes provide a GetTextStyle method.

[CONNECT U10] Confused about Item Types

$
0
0

I'm in the midst of trying to debug some application code using Item Types. I create an Item Type Library and Item Types in code. When I successfully "attach" an Item Type to an element, if I dump out information about discovered schemas. I see my ItemType Library under two entries:

FullName: DgnCustomItemTypes_SRSTest:Above__x0020__Ground__x0020__Slab

Discovered ECSchema: 'DgnCustomAttributes'

FulleName: DgnCustomItemTypes_SRSTest:Above__x0020__Ground__x0020__Slab

Discovered ECSchema: 'Bentley_Standard_CustomAttributes'

What's the difference and why is the Library (SRSTest) there under two different ECSchemas?

Bruce

[CONNECT VBA] New Classes in Update 11

$
0
0

There doesn't seem to be a What's New for VBA, so here are a couple of things I've noticed.

Printing

There are some classes and event handlers for printing introduced with Update 11 …

  • PrintBeginElementParam Object
  • PrintManager Object
  • PrintResymbolize Event
  • PrintResymbolizeParam Object

Item Types

Update 10 introduced new classes for managing and creating Item Types …

  • ItemType Object
  • ItemTypeLibraries Object
  • ItemTypeLibrary Object
  • ItemTypeProperty Object
  • ItemTypePropertyHandler Object

[CONNECT U10 MDL] mdlBspline_extractCurve() is missing

$
0
0

Hi,

actually I'm migrating a V8i-MDL to Connect.

Linking my MDL App with mdlbltin.lib, results in a LNK2019 error, Symbol "__imp_mdlBspline_extractCurve" is missing.

This function is contained in msbspline.fdf, so compiling works fine, but mdlBspline_extractCurve() seems not to be compiled into Microstation. It is missing in the ustation.dll, when I open this file with the Visual Studio Dependency Walker.

I have to stroke a Bspline-Curve contained in an element descriptor. In my V8i-MDL I did this calling mdlBspline_extractCurve() first, filling in a MSBsplineCurve structure, and then call mdlBspline_evaluateCurve() to stroke the curve.

How is this task solved on Connect?

Tom

[V8i Addin C#] MDL Application Type

$
0
0

I'm programming a Microstation C # Addin (MDL) and noticed an Addin's attribute is [Addin.ApplicationType = MdlApplicationType ...]. They can be MdlApplicationType.InitApp, User, AutoDgn, Codeset, Video, PlotDriver ....
I want to ask how are these different? and where can i find the instructions for using them?


Tfmodify property

$
0
0

sending key in"  CadInputQueue.SendKeyin "" & "tfmodify property " & ele(i).ID.Low & " x " & x.Value & """

to add datagroup information to ( Form or Solid )don't work, but it works with those elements which are originally cells .

do you have an idea how to override this issue?

addelementS method [VBA]

$
0
0

Bonjour,

I try to round off several lineelement

Dim Sc As ElementScanCriteria
Dim Ee As ElementEnumerator
Set Sc = New ElementScanCriteria
Sc.ExcludeAllTypes
Sc.IncludeType msdElementTypeLine
Set Ee = ActiveModelReference.Scan(Sc)
Dim LLanc As LineElement
Dim PtLL1 As Point3d
Dim PtLL2 As Point3d
Dim Ar() As Element
Do While Ee.MoveNext
    Dim LLNew As LineElement
    Set LLanc = Ee.Current
        With LLanc.startPoint
        PtLL1 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
        End With
        With LLanc.EndPoint
        PtLL2 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
        End With
    Set LLNew = CreateLineElement2(LLanc, PtLL1, PtLL2)
    ActiveModelReference.RemoveElement LLanc'ActiveModelReference.AddElement LLNew ' doesn't work if ee > 1024
Loop
RedrawAllViews

Doesn't work if the number of lines is up to 1024... 210

So I made a trick not very academic with « if..then.. end if » and « goto »

Suite:
If Ee.MoveNext Then
    Set LLanc = Ee.Current
    With LLanc.startPoint
    PtLL1 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
    End With
    With LLanc.EndPoint
    PtLL2 = Point3dFromXYZ(Round(.X, 3), Round(.Y, 3), Round(.Z, 3))
    End With
    Set LLNew = CreateLineElement2(LLanc, PtLL1, PtLL2)
    ActiveModelReference.RemoveElement LLanc
    ActiveModelReference.AddElement LLNew
    Ee.MoveNext
    GoTo Suite
End If
RedrawAllViews

I’d like tu use addelements method but i don’t see a example,

I ‘ve tried namedgroup, elementenumerator , arrays seems to be the best way but i failed

Does anyone have an example? Or help

How do you guys go about vertically aligning an element of unknown height in a div?

$
0
0

I've always had to resort to using tables with valign, because I cannot ever figure out a good option in css. How do you guys do it?

Here's a use case. I have an image with a max height and width of 50px in a div that's 50px x 50px. The image will scale, so if it's not perfectly square, it will either be 50px wide or 50 px tall, with the other dimension proportional, so it still looks normal.

The problem is, when the image is not square and 50 px wide, I want it to be centered vertically, but the only way I ever can figure to do that is with a table.

I've tried vertical align with line heights set and all that jazz, but it never seems to work for me in css. Any ideas? Here's some sample html and css

Just remember that my image isn't always this width and height, that's dynamically set via back end code to keep the image proportional

<div class="badgeImage">
<img id="mainContent_ctl00_rptActiveAchBadges_ctl00_bnimgBadgeImage" src="someImage.png" style="height:42px;width:64px;">
</div>

<div class="badgeName">
<div title="Exam 00001" class="tooltip"><span title="">Exam 00001</span></div>
</div>


.badgeImage
{
height: 64px;
width: 64px;
text-align: center;

}
.badgeName
{
display: block;
margin-top: 5px;
}

[CONNECT C++] TextField in Cell not Updating

$
0
0

communities.bentley.com/.../AreaAnnotator9.dgn

The attached DGN file has a single model.  The model contains four shape elements.  Each shape is annotated using text fields.  Some text fields show Item Type property values; others show element properties such as area and perimeter.

Text Fields in Text Node are OK

The two green shapes are annotated each with a text node that contains several text fields including area, alternative area and perimeter.  If you use MicroStation's modify element tool to change a green shape element you can see that all the element property text fields update themselves to show the shape's new metrics.  That's the behaviour I expect.

Text Fields in Cell don't all Update

The two brown shapes are annotated each with a cell that contains plain text elements and also several text fields including area and perimeter.  If you use MicroStation's modify element tool to change a brown shape element you can see that the element property text fields do not all update themselves to show the shape's new metrics.  That's not the behaviour I expect. I'm puzzled!

  • Am I attempting the impossible by placing text fields in a cell? 
  • Have I created the text fields in the cell correctly?
  • Should those text fields that reflect element properties all update themselves when the host shape is modified?

Note: This problem seems to be a bug in MicroStation CONNECT, as mentioned by Paul Connelly below.  If I open the same DGN file with MicroStation V8i, the text fields in the cell update as expected.

Visual Studio Tools for MicroStation V8 & Connect Editions

Viewing all 4331 articles
Browse latest View live


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