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

[C#.NET AddIn CONNECT] How to assign a GraphicGroup to a new linestring

$
0
0

Hi there,

I want to create a linestring and add it to the model in a certain graphicgroup.
Would anyone know how to do this? Problem is that ElementPropertiesSetter class does not seem to have something for this.
In the function to create the linestring, I have this:

    ElementPropertiesSetter propsSetter = new ElementPropertiesSetter();
    propsSetter.SetLevel(Bentley.MstnPlatformNET.Settings.ActiveLevelId);
    //  ...
    //Non existent:
    //propsSetter.SetGraphicGroup(Bentley.MstnPlatformNET.Settings.CurrentGraphicGroup);
    var retElem = new LineStringElement(Session.Instance.GetActiveDgnModel(), null, m_points.ToArray());
    propsSetter.Apply(retElem);

Best regards, Jan Willem


[Connect update 7 .NET] Using DgnElementSetTool

$
0
0

Hi,

I am trying to understand how to use DgnElementSetTool..

I want to locate element, accept located element and then process that element.

I think I need to use function " bool NeedAcceptPoint()". However I am not sure

when this function is actually called.

According to API documentation "Called after populating tool's ElementAgenda to see if an explict data point is required before accepting and calling _ProcessAgenda".

Which function populates ElementAgenda, is it BuildLocateAgenda?

This is my code (NeedAcceptPoint is never called):

        protected override bool OnDataButton(BDPN.DgnButtonEvent ev)
        {
            //Locate element.
            LocateOneElement(ev, true);
            BDPN.HitPath hitPath = DoLocate(ev, true, (int)BDPN.ComponentMode.Innermost);

           
            if (null != hitPath)
            {
                BDPN.Elements.Element sel_el = hitPath.GetHeadElement();
                if (sel_el.ElementType == BDPN.MSElementType.Line)
                {
                    BDPN.NotificationManager.OutputPrompt("Line Selected");
                    BuildLocateAgenda(hitPath, ev);

                    uint test = ElementAgenda.GetCount();
                    HiliteAgendaEntries(true);
                }
                else
                {
                    //OnRestartTool();
                }
                

            }

            return true;
        }

Appriciate any help

Nenad

[CONNECT U11] Missing (still) SystemCallback event

$
0
0

I had identified a missing function SystemCallback event 4 years ago here. It appears to still be missing.

Bruce

无法访问include里Refcounted文件的::operator new(protected成员)

$
0
0

/*-------------------------------------------------------------+
|   HelloWorld.cpp                                                |
+-------------------------------------------------------------*/
#include <Mstn\MdlApi\MdlApi.h>
#include <DgnPlatform\DgnPlatformApi.h>
#include <DgnView\DgnElementSetTool.h>
#include "HelloWorldCmd.h"

USING_NAMESPACE_BENTLEY_DGNPLATFORM
USING_NAMESPACE_BENTLEY_MSTNPLATFORM
USING_NAMESPACE_BENTLEY_MSTNPLATFORM_ELEMENT

double g_1mu;

struct PlaceBsSurfaceTool : DgnPrimitiveTool
{
	PlaceBsSurfaceTool(int toolId, int promptId) : DgnPrimitiveTool(toolId, promptId) {}

	bool CreateBsSurface(EditElementHandleR eeh, DPoint3dCP pBasePt)
	{
		MSBsplineSurface bsSurface;
		MSBsplineCurve   bsCurves[4];
		DPoint3d         center[4];
		RotMatrix        rMatrix[4];
		double           radius = g_1mu / 2;

		center[0] = center[1] = center[2] = center[3] = *pBasePt;
		center[0].x += radius;
		center[1].x += g_1mu;     center[1].y += radius;
		center[2].x += radius;    center[2].y += g_1mu;
		center[3].y += radius;

		DVec3d xVec = DVec3d::From(1, 0, 0), negativeXVec = DVec3d::From(-1, 0, 0);
		DVec3d yVec = DVec3d::From(0, 1, 0), negativeYVec = DVec3d::From(0, -1, 0);
		DVec3d zVec = DVec3d::From(0, 0, 1);
		rMatrix[0].InitFrom2Vectors(xVec, zVec);  //Front View
		rMatrix[1].InitFrom2Vectors(yVec, zVec);  //Right View
		rMatrix[2].InitFrom2Vectors(negativeXVec, zVec);  //Back View
		rMatrix[3].InitFrom2Vectors(negativeYVec, zVec);  //Left View

		for (int i = 0; i < 4; i++)
		{
			bsCurves[i].InitEllipticArc(center[i], radius, radius, 0, PI, &rMatrix[i]);
		}
		if (SUCCESS != mdlBspline_coonsPatch(&bsSurface, bsCurves))
		{
			for (int i = 0; i < 4; i++)
				mdlBspline_freeCurve(&bsCurves[i]);
			return false;
		}
		DraftingElementSchema::ToElement(eeh, bsSurface, nullptr, *ACTIVEMODEL);
		mdlBspline_freeSurface(&bsSurface);
		for (int i = 0; i < 4; i++)
			mdlBspline_freeCurve(&bsCurves[i]);
		return true;
	}

	virtual void _OnPostInstall() override
	{
		_BeginDynamics();
		AccuSnap::GetInstance().EnableSnap(true);
		__super::_OnPostInstall();
	}

	virtual void _OnRestartTool() override
	{
		PlaceBsSurfaceTool *pTool = new PlaceBsSurfaceTool(GetToolId(), GetToolPrompt());
		pTool->InstallTool();
	}

	virtual void _OnDynamicFrame(DgnButtonEventCR ev) override
	{
		EditElementHandle eeh;
		if (!CreateBsSurface(eeh, ev.GetPoint()))
			return;

		RedrawElems redrawElems;
		redrawElems.SetDynamicsViews(IViewManager::GetActiveViewSet(), ev.GetViewport());
		redrawElems.SetDrawMode(DRAW_MODE_TempDraw);
		redrawElems.SetDrawPurpose(DrawPurpose::Dynamics);
		redrawElems.DoRedraw(eeh);
	}

	virtual bool _OnDataButton(DgnButtonEventCR ev) override
	{
		EditElementHandle  eeh;
		if (CreateBsSurface(eeh, ev.GetPoint()))
			eeh.AddToModel();
		_OnReinitialize();
		return true;
	}

	virtual bool _OnResetButton(DgnButtonEventCR ev) override
	{
		_EndDynamics();
		_ExitTool();
		return true;
	}
};

void createALine(WCharCP unparsed)
{
	DPoint3d basePt = DPoint3d::FromZero();

	EditElementHandle eeh;
	DSegment3d seg;
	seg.Init(basePt, DPoint3d::From(basePt.x + g_1mu * 2, basePt.y + g_1mu));
	ICurvePrimitivePtr pCurve = ICurvePrimitive::CreateLine(seg);
	DraftingElementSchema::ToElement(eeh, *pCurve, nullptr, ACTIVEMODEL->Is3d(), *ACTIVEMODEL);
	eeh.AddToModel();
}

void createAComplexShape(char *unparsed)
{
	MSElement        el;
	MSElementDescrP  edP = NULL;
	DPoint3d         basePt, pts[3];
	
	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;

	EditElementHandle eeh;

	pts[1].x += g_1mu*0.3;    pts[1].y += g_1mu*0.7;
	pts[0].x += g_1mu;        pts[0].y += g_1mu;
	DEllipse3d arcPts = DEllipse3d::FromPointsOnArc(pts[2], pts[1], pts[0]);
	CurveVectorPtr pCurveVec = CurveVector::Create(CurveVector::BOUNDARY_TYPE_Outer);
	pCurveVec->Add(ICurvePrimitive::CreateArc(arcPts));

	pts[1].x = pts[0].x;    pts[1].y = pts[2].y;
	pCurveVec->Add(ICurvePrimitive::CreateLineString(pts, 3));
	DraftingElementSchema::ToElement(eeh, *pCurveVec, nullptr, ACTIVEMODEL->Is3d(), *ACTIVEMODEL);
	eeh.AddToModel();
}

void createAProjectedSolid(char *unparsed)
{


	DPoint3d         basePt, pts[6];
   
	basePt.x = 3.2*g_1mu;     basePt.y = -0.6*g_1mu;    basePt.z = -1.2*g_1mu;
	pts[0] = basePt;

	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;

	CurveVectorPtr pCurveVec = CurveVector::CreateLinear(pts, 6, CurveVector::BOUNDARY_TYPE_Outer);
	DVec3d extrusionVec = DVec3d::From(0, 0, g_1mu);
	DgnExtrusionDetail  data(pCurveVec, extrusionVec, true);
	ISolidPrimitivePtr pSolid = ISolidPrimitive::CreateDgnExtrusion(data);
	EditElementHandle eeh;
	DraftingElementSchema::ToElement(eeh, *pSolid, nullptr, *ACTIVEMODEL);
	eeh.AddToModel();
}

void createABsplineSurface(WCharCP unparsed)
{
	PlaceBsSurfaceTool *pTool = new PlaceBsSurfaceTool(0, 0);
	pTool->InstallTool();
}

MdlCommandNumber cmdNums[] =
{
	{ (CmdHandler)createALine,		        CMD_HELLOWORLD_CREATE_LINE },
	{ (CmdHandler)createAComplexShape,	    CMD_HELLOWORLD_CREATE_COMPLEXSHAPE },
	{ (CmdHandler)createAProjectedSolid,	CMD_HELLOWORLD_CREATE_PROJECTEDSOLID },
	{ (CmdHandler)createABsplineSurface,    CMD_HELLOWORLD_CREATE_BSPLINESURFACE },
	0
};

extern "C" DLLEXPORT void MdlMain(int argc, WCharCP argv[])
{
	ModelInfoCP pInfo = ACTIVEMODEL->GetModelInfoCP();
	g_1mu = pInfo->GetUorPerStorage();

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

	mdlSystem_registerCommandNumbers(cmdNums);

}

(这是源文件的代码,错误在164行)

refcounted原文件是这样的:

当我把protected换成public后,以上问题就消失了:

但是这样改包含文件好像不科学,请问有没有更好的方法来解决这个问题?

[CONNECT C++] CurveVector::IsPhysicallyClosedPath

$
0
0

CurveVector::IsPhysicallyClosedPath tells me if, say, a line-string has coincident start and end points.  It looks like a shape, but remains an open curve vector. 

I want to measure the area of that not-quite-a-shape.  Should I copy the line-string and create a closed CurveVector that I can measure?  Is there a CloseShape method I can call or should I extract the line-string points and create a new closed shape? 

CurveVector contains some arcane methods: is there another way to get a closed CurveVector from a CurveVector that passes the IsPhysicallyClosedPath test?

Microstation pops up this message: Symbol not published: type='Text' id=1 label="基准弧半径(B):" ,when I'm doing second development of MDL-CE(Update4)

$
0
0

what's wrong with my program,maybe?Or something else?

Having Trouble Implementing Node.JS

$
0
0

Hi all, I am .NET developer and have been programming in .NET for the last 5 years. Moreover, I am starting to expand my skills so I picked up the most popular language, JavaScript nowadays for developers. 

I am creating a e-com based project  and need to add a generator for promo codes. Can anyone help me out? I have some design inspirations. 

How to create text node with subscript/superscript by MVBA?

$
0
0

Hello All,

I can create text node without subsctipt/superscript, I'd like to know how to create  subcript/superscript, can someone show me some sample code? Thanks a lot!


[CONNECT C++] Create custom IECInstance formatter for ItemType property

$
0
0

I have existing code that creates an IECInstance formatter for the area property of my Item Type. 

bool    CreateAreaFormatter  (IECInstancePtr&                 formatInstance,
                             int                              nUnits,
                             int                              accuracy,
                             Annotator::AreaDecoratorOptions  decorator)  
{
  ECN::ECSchemaPtr      formatSchema;
  if (SchemaFactory::GetMstnPropertyFormatterSchema (formatSchema))
  {
    WCharCP                 AreaClassName { L"AreaClass" };
    ECN::ECClassCP          formatClass   { formatSchema->GetClassCP (AreaClassName) };
    StandaloneECEnablerP    enabler       { formatClass->GetDefaultStandaloneEnabler () };
    StandaloneECInstancePtr localInstance { enabler->CreateInstance () };
    if (localInstance.IsValid ())
    {
      WCharCP        PropUnits       { L"Units" };
      ECValue        units           { nUnits };
      localInstance->SetValue (PropUnits, units);
      WCharCP        PropAccuracy    { L"Accuracy" };
      ECValue        valAccuracy     { accuracy };
      localInstance->SetValue (PropAccuracy, valAccuracy);
      WCharCP        PropUnitDecorator  { L"UnitDecorator"  };
      ECValue        valDecorator    { decorator };
      localInstance->SetValue (PropUnitDecorator, valDecorator);

      formatInstance  = localInstance;
    }
  }
  return formatInstance.IsValid ();
}

That uses the information in ECSchema..\MicroStation\ECSchemas\Standard\Units_Schema.01.00.ecschema.xml to obtain numeric conversions and labels.

Formatted Area Labels

I would like to create formatter for hectares.  Hectares are commonly used in Europe and rest of world to measure area.  Hectares are similar in scale to acres, used in the US.  Unfortunately, Hectares are not included in the MstnPropertyFormatter schema.

I am not able to run my command button created through userform in vba editor for running a macro in microstation v8i ss4 drawing.

$
0
0

I have recorded a macro in microstation v8i ss4 and I have created a command button through userform in visual basic editor. But I am not able to place the command button in the drawing and run the macro. How should I link the command button to the macro so that when I place the command button in the drawing and when the user clicks on that button the macro should run.

Need help to rename view group batch process for dgn export from autocad

$
0
0

Would someone to have the script txt, vba, mvba or macro to run batch process for rename

"Model" to "Design Model" (is the tab name from autocad on model space)


"Layout1" to Plot Model" (from autocad is the name of sheet number on paper space "r183hf01)

I know that I can manually rename by open one by one, it take to much time for a lot of dgn files

Please help

Thanks

MicroStation Addins

$
0
0

I am using MicroStation Connect Edition Update 11 - Version 10.11.00.6, Windows 10, Visual Studio 2015 and .Net Framework for the project is set at 4.6.1.  I am trying to build the MicroStation Addin examples by Yongan Fu but I'm receiving errors on the example in Step 2.  My code is as follows:

using System;
using Bentley.MstnPlatformNET.InteropServices;
using Bentley.Interop.MicroStationDGN;
namespace csAddins
{
    class CreateElement
    {
        public static void LineAndLineString()
        {
            Application app = Utilities.ComApp;
            Point3d[] pntArray = new Point3d[5];
            pntArray[0] = app.Point3dZero();
            pntArray[1] = app.Point3dFromXY(1, 2);
            pntArray[2] = app.Point3dFromXY(3, -2);
            pntArray[3] = app.Point3dFromXY(5, 2);
            pntArray[4] = app.Point3dFromXY(6, 0);
            LineElement oLine = app.CreateLineElement1(null, ref pntArray);
            oLine.Color = 1;
            oLine.LineWeight = 2;
            app.ActiveModelReference.AddElement(oLine);
        }
    }
}
The program builds successfully but when I try to load the addIn into MicroStation, I get the follow error:
************** Exception Text **************
System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
   at System.StubHelpers.MngdSafeArrayMarshaler.ConvertSpaceToNative(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome)
   at Bentley.Interop.MicroStationDGN.Application.CreateLineElement1(Element Template, Point3d[]& Vertices)
   at csAddins.CreateElement.LineAndLineString() in C:\Users\larry.smart\OneDrive - Union Tank Car Company\Documents\MicroStation\C# Addins\Hello World\csAddins\csAddins\CreateElement.cs:line 19
   at csAddins.MyAddin.Run(String[] commandLine) in C:\Users\larry.smart\OneDrive - Union Tank Car Company\Documents\MicroStation\C# Addins\Hello World\csAddins\csAddins\MyAddin.cs:line 15
   at Bentley.MstnPlatformNET.AddIn.Load(String[] commandTail, IntPtr mdlDesc)
Line 19 is the following code from above:
LineElement oLine = app.CreateLineElement1(null, ref pntArray);
Does anyone know what this error message is?
Thanks,
Larry

[V8i C++] Displaying point clouds with GetFPoints

$
0
0

Hi,

I'm trying to display a point cloud using the IPointCloudDrawParams. I managed to do this with the GetDPoints method. However it requires to keep my points as DPoint3d.  To save some memory I would prefer to use FPoint3d and GetFPoints method. The problem is that by using FPoint3d instead of DPoint3d I'm not able to keep a good precision for large coordinates. Is there a way to draw a cloud in a local coordinate system and then translate it to the proper position by adding a vector?

Thanks

Wojciech

[CONNECT C++] ElementGraphicsTool vs DgnElementSetTool

$
0
0

I want to write a cell picker tool.  My goal is to modify a nested cell inside the picked cell element.

I started to write a picker class inheriting from DgnElementSetTool. On reviewing the MicroStationAPI help doc., I wonder if a class inheriting from ElementGraphicsTool would be a better choice?  There is no example of ElementGraphicsTool that would influence my decision.

[CONNECT C++] Could not extract geometries from an extended element containing a smart solid


[CONNECT C++] MicroStationAPI ActiveSettings documentation incorrect

$
0
0

MicroStationAPI help lists a number of methods under topic Active Settings.  For example,

static BentleyStatus  GetValue (bool &value, ActiveBoolParams paramName) 
  Gets the value of an active MicroStation setting of type boolean 

However, those methods are in namespace ActiveParams not ActiveSettings.  Please make the documentation more accurate and helpful!

VBA and Microstation Update 11

$
0
0

I have a macro working correctly with the Update 10 but not working anymore with Update11........

Dim oItemPropHandler As ItemTypePropertyHandler
Dim oItemLibs As ItemTypeLibraries
Dim oItemLib As ItemTypeLibrary
Dim result As String
Dim result2 As String
Dim result3 As String
Dim oItems As Items
Dim oItem As ItemType
Dim oEE As ElementEnumerator
Dim BSP As Element

Set oItemLibs = New ItemTypeLibraries
Set oItemLib = oItemLibs.FindByName("TOTO")
Set oItem = oItemLib.GetItemTypeByName("TUTU")
Set oEE = ActiveModelReference.GetSelectedElements
Do While oEE.MoveNext
Set BSP = oEE.Current
Set oItems = BSP.Items
oItems.Refresh ("TOTO")
Loop

Microstation Connect crashes at the line       

" oItems.Refresh ("TOTO")"

MicroStation SDK Dimensions Example

$
0
0

I am trying to load an example from the MicroStation SDK examples; DimensionsExample.  When I try to load the addin, I get the following error:

System.BadImageFormatException: Could not load file or assembly 'dimensionsexample' or one of its dependencies. The module was expected to contain an assembly manifest.

Does anyone know what is causing this error?

When I compile the code, I do get this message:

mt.exe -manifest C:\Users\LARRY~1.SMA\AppData\Local\Temp\Bentley\MicroStationSDK\objects\DimensionsExample.dll.Manifest -outputresource:"C:\PROGRA~1\Bentley\MICROS~1\MICROS~1\mdlapps\DimensionsExample.dll";2'mt.exe' is not recognized as an internal or external command,operable program or batch file.

I am running MicroStation Connect Edition Update 11 - Version 10.11.00.36, Windows 10 and MicroStation SDK version 10.11.0042.

Thanks,

Larry

Update Textstyle Name Not working

$
0
0

I am using OpenRoads Designer CONNECT Edition Release 4 Update 6 - Version 10.06.00.38.

I wrote a VBA script that uses element enumerator to scan for all text and will pass the current enumerator as a text element to a function. This function then determines the textstyle to apply.

A portion of the main module is below



            For Each omodel In o.ActiveDesignFile.Models
                oCriteria.ExcludeAllTypes' Scan for normal cells
                oCriteria.IncludeType msdElementTypeTextNode' Scan for shared cells
                oCriteria.IncludeType msdElementTypeText

                Set oEnumerator1 = omodel.Scan(oCriteria)
                Do While oEnumerator1.MoveNext
                
                    If oEnumerator1.Current.Type = msdElementTypeText Then
                        oEnumerator1.Current.IsHighlighted = True
                        
                        replaced_text = Text_StyleFix(oEnumerator1.Current.AsTextElement)
                        If replaced_text <> "" And InStr(replaced_text, ",") > 0 Then
                            oEnumerator1.Current.Rewrite
                            update_count = update_count + 1
                        Else
                            replaced_text = "None"
                        End If
                    End If

The text_stylefix function sets the text style using below. A string is returned for tracking purposes.

        Set oText.TextStyle = ActiveDesignFile.TextStyles(Replacement_Style)

Then I rewrite at the enumerator level. This line above updates all the text attributes other than the text name. Is there a reason the textstyle name is not being updated, but everything else is?

Thanks

Jacob Armour

[MDL] Determining OptionButton SubItem widths

$
0
0

I've got a "blank" (i.e. no SubItems) OptionButton definition in my resource file. I "insert" items dynamically using mdlDialog_optionButtonInsertItem(). When the OptionButton is displayed in the dialog, it contains the entries, but the DialogItem's "width" is zero (I have it set to 0 in the SExtent struct).

1.Is there any way to determine the "width" of a SubItem when inserted into the OptionButton? Just multiply the number of characters times some value (assuming fixed width font)?

2.If a width CAN be determined, is it possible to update the SExtent of the OptionButton so when it open, the "width" is set properly and you can see the entries?

Bruce

Viewing all 4331 articles
Browse latest View live


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