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

[Connect - MDL / C++] Copying elements with items and labels by fence will give you unwanted cell elements

$
0
0

Hi,

I've got some problems when I copy elements with items and labels from a reference file. The elements, items and labels a copied but extra cell elements with the label text are added too.

I've attached a design file that contains two models: a design model and sheet model in which I've attached the design model as reference.

(Please visit the site to view this file)

If you run the code listed below you will see the problem.

// create shape element
	DPoint3d pts[5];
	pts[0].x = pts[0].y = 0;
	pts[1].x = 500;
	pts[1].y = 0;
	pts[2].x = 500;
	pts[2].y = 500;
	pts[3].x = 0;
	pts[3].y = 500;
	pts[4].x = pts[4].y = 0;
	for (int i = 0; i < 5; i++)
		pts[i].z = 0;
	EditElementHandle eehShape;
	ShapeHandler::CreateShapeElement(eehShape, NULL, pts, 5, true, *ISessionMgr::GetActiveDgnModelRefP());

	// define fence by shapeElement
	IndexedViewSetR viewSet = IViewManager::GetManager().GetActiveViewSet();
	FenceManagerR fenceManager = FenceManager::GetManager();
	fenceManager.DefineByElement(&eehShape, viewSet.GetViewport(tcb->lstvw));

	FenceParamsP fenceParams = FenceParams::Create(ISessionMgr::GetActiveDgnModelP());
	fenceManager.InitFromActiveFence(*fenceParams, false, false, FenceClipMode::None);

	// build modelreflist
	DgnModelRefListP modelRefList;
	mdlModelRefList_create(&modelRefList);
	mdlModelRefList_add(modelRefList, ISessionMgr::GetActiveDgnModelP());

	ModelRefIteratorP   mrIteratorP;
	if (mdlModelRefIterator_create(&mrIteratorP, mdlModelRef_getActive(), MRITERATE_Root | MRITERATE_PrimaryChildRefs, -1) == SUCCESS)
	{
		DgnModelRefP modelRef = mdlModelRefIterator_getFirst(mrIteratorP);
		while (modelRef)
		{
			mdlModelRefList_add(modelRefList, modelRef);
			modelRef = mdlModelRefIterator_getNext(mrIteratorP);
		}
		mdlModelRefIterator_free(&mrIteratorP);
	}

	// build element agenda and free modelreflist
	ElementAgenda elmAgenda;
	fenceManager.BuildAgenda(*fenceParams, elmAgenda, modelRefList, false, false, false);
	mdlModelRefList_free(&modelRefList);

	// copy the elements in the elementAgenda
	ElementCopyContext elmCopyContext(ISessionMgr::GetActiveDgnModelP());
	elmCopyContext.SetLevelHandling(CopyContextLevelOption::CopyIfNotFound);

	for (UInt index = 0; index < elmAgenda.GetCount(); index++)
	{
		EditElementHandleP eehP = elmAgenda.GetEntryP(index);
		elmCopyContext.DoCopy(*eehP);
		eehP->AddToModel();
	}

Any ideas to solve this problem ?

TIA, Evan


How to Use macro to open and copy place fence của 1 file reference  Order (I’m a new member)

$
0
0

Have a good day.

How to create macro:

Example: file 1: 00001*.dgn copy from file: *00001.dgn

File : 00002*.dgn copy from file: *00002.dgn

File: 00003*.dgn copy from file: *00003.dgn

File: 00004*.dgn  copy from file: *00004.dgn

Image: www.upsieutoc.com/.../TPADaE

How to create Macro?

Thanks.

[Microstation Connect Update4 MDL C++] how to implement the function of tool sweep surface along curves in c++ (sweep two along one)?

[microstation connect update4 MDL c++] SolidUtil::Create::BodyFromLoft failed in my program, why?

$
0
0
extract boundary curves from top and bottom b-surface, and then making b-surface with the two boundary curves failed, please give me a reasion, DGN file in attachment below,  my code as follow:
 CurveVectorPtr profileVec[2];
 // 1. extract the first boundary curves from b-surface
 {
  ElementId id = 6772;
  std::vector<MSElementDescrP> elemVec;
  DgnModelRefP model = ISessionMgr::GetManager().GetActiveDgnModelRefP();
  for each (ElementHandle elem in model->GetReachableElements())
  {
   if (elem.GetElementId() == id) // bspline surface
   {
    MSElementDescrP tmp = 0;
    mdlAssoc_getElementDescr(&tmp, NULL, elem.GetElementId(), ACTIVEMODEL, FALSE);
    elemVec.push_back(tmp);
   }
  }
  if (elemVec.size() != 1)
   return ;
  MSElementDescrP edp = elemVec[0];
  ElementHandle eh(edp, true, true);
  ISolidKernelEntityPtr out;
  if (SUCCESS != SolidUtil::Convert::ElementToBody(out, eh))
  {
   WString messageInfo = L"ElementToBody failed.";
   mdlDialog_openInfoBox(messageInfo.c_str());
   return ;
  }
  ISolidKernelEntity::KernelEntityType typ = out->GetEntityType();
  if (typ != ISolidKernelEntity::KernelEntityType::EntityType_Sheet)
  {
   mdlDialog_openInfoBox(L"not EntityType_Sheet");
   return ;
  }
  SolidUtil::Debug::DumpEntity(*out, L"12");
  bvector<ISubEntityPtr> subEntities;
  size_t nEdges = SolidUtil::GetBodyEdges(&subEntities, *out);
  if (nEdges != subEntities.size())
  {
   WString messageInfo = L"GetBodyEdges failed.";
   mdlDialog_openInfoBox(messageInfo.c_str());
   return ;
  }
  profileVec[0] = CurveVector::Create(CurveVector::BOUNDARY_TYPE_Open);
  for (int i = 0; i < subEntities.size(); i++)
  {
   CurveVectorPtr cvp;
   if (SUCCESS != SolidUtil::Convert::SubEntityToCurveVector(cvp, *(subEntities[i].get())))
   {
    mdlDialog_openInfoBox(L"SubEntityToCurveVector failed.");
    return;
   }
  
   profileVec[0]->Add(cvp);
  }
 }
//
 // extract the second boundary curves from b-surface
//
 {
  ElementId id = 6713;
  std::vector<MSElementDescrP> elemVec;
  DgnModelRefP model = ISessionMgr::GetManager().GetActiveDgnModelRefP();
  for each (ElementHandle elem in model->GetReachableElements())
  {
   if (elem.GetElementId() == id) // bspline surface
   {
    MSElementDescrP tmp = 0;
    mdlAssoc_getElementDescr(&tmp, NULL, elem.GetElementId(), ACTIVEMODEL, FALSE);
    elemVec.push_back(tmp);
   }
  }
  if (elemVec.size() != 1)
   return;
  MSElementDescrP edp = elemVec[0];
  ElementHandle eh(edp, true, true);
  ISolidKernelEntityPtr out;
  if (SUCCESS != SolidUtil::Convert::ElementToBody(out, eh))
  {
   WString messageInfo = L"ElementToBody failed.";
   mdlDialog_openInfoBox(messageInfo.c_str());
   return;
  }
  ISolidKernelEntity::KernelEntityType typ = out->GetEntityType();
  if (typ != ISolidKernelEntity::KernelEntityType::EntityType_Sheet)
  {
   mdlDialog_openInfoBox(L"not EntityType_Sheet");
   return;
  }
  SolidUtil::Debug::DumpEntity(*out, L"12");
  bvector<ISubEntityPtr> subEntities;
  size_t nEdges = SolidUtil::GetBodyEdges(&subEntities, *out);
  if (nEdges != subEntities.size())
  {
   WString messageInfo = L"GetBodyEdges failed.";
   mdlDialog_openInfoBox(messageInfo.c_str());
   return;
  }
  profileVec[1] = CurveVector::Create(CurveVector::BOUNDARY_TYPE_Open);
  for (int i = 0; i < subEntities.size(); i++)
  {
   CurveVectorPtr cvp;
   if (SUCCESS != SolidUtil::Convert::SubEntityToCurveVector(cvp, *(subEntities[i].get())))
   {
    mdlDialog_openInfoBox(L"SubEntityToCurveVector failed.");
    return;
   }
   profileVec[1]->Add(cvp);
  }
 }
 //  ----- create guide line
 bvector <DPoint3d> profilePts;
 profilePts.push_back({ 53568, 398560, 237 });
 profilePts.push_back({ 53568, 398560, 306 });
 CurveVectorPtr guideVec = CurveVector::CreateLinear(profilePts, CurveVector::BOUNDARY_TYPE_Outer);

 // 3 ---- Create Solid by Loft
 ISolidKernelEntityPtr solid;
 DgnModelP             pActiveModel = ISessionMgr::GetActiveDgnModelP();
 if (SUCCESS != SolidUtil::Create::BodyFromLoft(solid, profileVec, 2, &guideVec, 1, *pActiveModel, false, true))
 {
  mdlDialog_dmsgsPrint(L"Error in BodyFromLoft");
  return;
 }
 // 4 ---- Convert Solid to EditElementHandle and add it to model
 if (solid.IsValid())
 {
  EditElementHandle eeh;
  SolidUtil::Convert::BodyToElement(eeh, *solid, nullptr, *pActiveModel);
  //DraftingElementSchema::ToElement(eeh, *solid, nullptr, *pActiveModel);
  eeh.AddToModel();
 }
(Please visit the site to view this file)

Batch Process & BIM Level/Serial# Generator

$
0
0

Hey, this might be fairly fundamental or rudimentary for you, and if this is not the place to post this, please let me know where.  I am looking to generate a dgn with level names and level color properties as outlined in an excel file I created with an excel macro.  Then, what I am trying to do is find all elements in a list of dgns/prps and automating the classification and assignment of the levels to elements based on the serial number logic I came up with in the excel file that I have. (see below for the breakdown)

I have over 300 dgns and about 100 prp files.  The files are filled with elements of varying types on multiple number-based levels and different colors.  The issue is that I have a ton of files and the elements are not on levels that define their color "by level" and I can not just change the colors of the elements to "by level" due to how the files are set up and how I need to manipulate the elements in the future.  In essence different elements on the same level and different hard-coded color properties for elements.  I generated new BIM levels in Excel to split the identification of levels in a serial # based approach (basically going from 9 elements on 1 level and 3 hard-coded colors, to 9 elements on 3 levels with one "by level" color assigned to each level).

Been looking at Batch Processing, Microstation VBA, and Excel file incorporation and doing research on this concept ... sort of stuck at the moment, but I think it is possible to pull this off.  If there is any help or pointers let me know, here is an outline:

What I have:

300 DGNs

100 PRPs

1-70 Current Levels (Number-Based)

1-255 Colors (Index Number-Based)

###-####-##-### ("Model File Tracking" 001to400 - "New Level Generation" 0001to9999 - "Current (Legacy) Level Number" 01to70 - "Current Hard-Coded Color & Level Color Assignment" 001-255)

Looking to edit the design files (I have an archive version just in case) and add levels an move all elements to the new levels based on the classification per the serial number logic.

Is it possible to build something like this and scale it for the application over 400 files with the Batch process?  Any pointers?

[V8i VBA] Matrix3D and multiple rotations

$
0
0

In an existing project that I have posted about previously I can insert cells at known coordinates and calculate a rotation on the XY plane  so the cells are perpendicular to a target linear element (B-spline, complex shape etc..) I am currently using Matrix3dFromAxisAndRotationAngle where Z=2 and to date my target element has also been planar to the XY plane however I would now like to cater for situations where the target element is non-planar. I created a simple test using the existing code where the target element is line drawn parallel to the X axis and increasing its Z-value on the XZ plane. The cells are still inserted exactly as when the target element is planar. I'm just unsure how perform the 2nd rotation around the normal vector i.e.

  • can the rotation matrix be constructed to include both rotations (obviously using an alternative method instead of Matrix3dFromAxisAndRotationAngleor,
  • do I keep what I have and perform the 2nd rotation as an additional step?

[V8i VBA] ProjectPointOnPerpendicular problem

$
0
0

As an aside to my other live discussion thread, I was testing my existing code using the sloping line element but I changed the test coordinate so that it was no longer planar on the XY plane with the line element and its perpendicular intersection. I was curious to see if the ProjectPointOnPerpendicular would return the same coordinate it was planar. Sadly it doesn't and cells are result is that cells are no longer inserted perpendicular to the target element so its critical that I find a solution to ensure that the correct point is returned. I need the method to operate as just a the command 'Trim to Element' can project a line to intersect with a non-planar element. Reviewing the VBA on ProjectPointOnPerpendicular I noticed my old foe Matrix3D is the 2nd parameter and to date using elements planar to my coordinates, I have this parameter set to MatrixIdentity. I attempted the following modification having read a similar solution in another thread:

        Dim Axis                                  As Long
        Dim RotMatrix                             As Matrix3d

        Axis = 2
        dRadians = Radians(90)
        RotMatrix = Matrix3dFromAxisAndRotationAngle(Axis, dRadians)
    ...
       Case msdElementTypeLine, msdElementTypeLineString
                ProjectedPoint = oElement.AsLineElement.ProjectPointOnPerpendicular(SourceCoordinate, RotMatrix) 

This wasn't successful and the inserted cell matches the same rotation as using MatrixIndentity.

How can I calculate the 'theoretical' perpendicular intersection from a coordinate on its XY plane to an element which may have vertices that lie at varying Z coordinates?

[Connect update 6 NET API] DgnTorusPipe problem

$
0
0

Hi,

I have created DgnTorusPipe and trying to get DgnTorusPipeDetail from created element but getting null pointer as result.

I do not understand why function TryGetDgnTorusPipeDetail returns null pointer.

            DgnModel oModel = Session.Instance.GetActiveDgnModel();

            DPoint3d center = new DPoint3d(0, 0, 0);

            clsMicroStationUnits myCLS = new clsMicroStationUnits();
            center = myCLS.DPoint3d_ToUor(center);

            double con = myCLS.UOR_To_Master();
            double majorR = 1000 * con;
            double minorR = 100 * con;
            double angle = myCLS.convertAngleToRadian(90);

            myCLS = null;


            DVector3d vectorX = new DVector3d(1, 0, 0);
            DVector3d vectorY = new DVector3d(0, 1, 0);



            DgnTorusPipeDetail odata = new DgnTorusPipeDetail(center, vectorX, vectorY, majorR, minorR, angle, true);

            SolidPrimitive sample = SolidPrimitive.CreateDgnTorusPipe(odata);

            Element oElement = DraftingElementSchema.ToElement(oModel, sample, null);
            oElement.AddToModel();

            Bentley.DgnPlatformNET.Elements.SolidElement se = (SolidElement)oElement;
            SolidPrimitive sp = se.GetSolidPrimitive();


            DgnTorusPipeDetail dtpd = sp.TryGetDgnTorusPipeDetail();

thanks

Nenad


C# Microstation V8I 如何读取非当前的dgnlib文件中的元素?

$
0
0

我想将很多构件放在dgnlib的model中,然后做一个插件可以在某一个dgn文件中遍历选择的dgnlib文件中所有的model,将model中的构件以cell的方式插入到该dgn文件中,但不清楚c#读取dgnlib文件(或dgn文件,dgnlib文件是一种特殊的dgn文件,因此应该同于读取dgn文件的方式)的方法。

请老师们指点一下。

[Connected Edition] Rotation-X inconsistent in different machines

C++或C# 如何控制打开的DgnModel 默认Construction类型的元素是不现实的?

$
0
0

C++或C# 如何控制打开的DgnModel 默认Construction类型的元素是不现实的?比如Drawing或Sheet类型的DgnModel不显示构造线元素

如图:

[CONNECT C++] Predefined variables not loaded before rest of workspace

$
0
0

I just noticed that in Update 6, all of the workspace configuration files get loaded before the MicroStation Manager is displayed.

This seems to be different to all previous versions of MicroStation back to v5 at least, and makes it much harder for me to configure anything.

My program uses a configuration file to set up its own paths, and it no longer works because some of the predefined variables have not loaded until after the MicroStation Manager is displayed.

For example, my script uses a simple shared config file to differentiate the different platforms in order to supply the correct binaries for each platform/version.

%if defined (_VERSION_10_0)

# Do this for Connect Edition
...

%elif defined (_VERSION_8_11)

# Do this for MicroStation V8i
...

%elif defined (_VERSION89)

# Do this for MicroStation XM
...

%elif defined (_VERSION80)

# Do this for MicroStation V8.5
...

%endif


This does not work in Connect because it seems the predefined variable has not yet been defined before the MM is shown. It also seems that all config files are read at this point, whereas in previous MicroStation versions, config files were loaded after the MM and all predefined variables were already defined.

Is there any way I can get my config to be loaded after all variables are predefined in Connect? Obviously I could manually load a config file in code, but I need to set my paths before any code is called.

Cheers.

[CONNECT C++] DialogItemHookHandler Lifetime

$
0
0

I found the DialogItemHookHandler and DialogHookHandler classes tucked away in a corner of the MicroStationAPI help doc.  They simplify the task of writing a dialog or dialog item hook (a.k.a. callback function).  The classes provides virtual callback methods that elegantly replace the switch statements we otherwise have to write in a hook function.

What's not clear is the lifetime management of a class that inherits from DialogItemHookHandler or DialogHookHandler.  The class is instantiated in the help examples by a static factory method...

static void HookResolve (DialogItemMessage *dimP)
{
  if (DITEM_MESSAGE_HOOKRESOLVE == dimP->messageType)
  {
    dimP->u.hookResolve.hookHandlerP = new MyItemHookHandler (dimP->db, dimP->dialogItemP);
    dimP->msgUnderstood = true;
  }
}

What is the lifetime of the Hook Handler created by that factory method?  Presumably it's destroyed when the dialog or item terminates.  But the destruction mechanism is not, as far as I can see, published.  Could I use an object that's instantiated elsewhere?  That is,

dimP->u.hookResolve.hookHandlerP = MyExistingHookHandler;
MyExistingHookHandler.SetPointers (dimP->db, dimP->dialogItemP);

But, if I do that, then the Hook Handler destruction mechanism will attempt to destroy something that it doesn't own.

Why do I ask this question?  Elegant though the new classes may be, then don't eliminate the distributed nature of dialog item functionality.  Some functionality is built-in to MDL dialog items.  Other functionality we add using these hook classes.  But, the classes remain distinct from one another.  For example, I have a dialog box that contains several dialog items.  I want to control the visibility of some items depending on the state of a ComboBox.  I have a DialogItemHookHandler class for the ComboBox and a DialogHookHandler for the dialog box.  On the ComboBox QueueCommand event, I tell the dialog to hide some items and reveal others.  That all works fine, but I'm having to use mdlDialog_xxx functions to send a message from the ComboBox handler to the DialogHookHandler.  That works, but I have two distinct classes filled with comments about who does what and to whom.

It would be useful to have, say, a class hierarchy that enabled me to say that the ComboBox handler class is subordinate or contained within the dialog handler class.  I don't see a way to do that right now.

From V8i to Connect with KISolid functions

$
0
0

Hello,

we are in the process of migrating from v8i to Connect SDK. We have many dlls and we need a little help to find some references that are probably relocated, or new ways to do the things we used to do through the old SDK.

Lately we had been programming in C#, wrapping dlls as needed.

Here is an example of code from a typical situation.

What is the straightest way to write this piece of code to work with Connect edition?

[DllImport("stdkisolid.dll")]
private static extern void mdlKISolid_beginCurrTrans(int modelRef);

[DllImport("stdkisolid.dll")]
private static extern int mdlKISolid_listCreate(ref int lP);

... // Some other imports from stdkisolid.dll

public List<Edge> List(Element element, ModelReference model)
{
List<Edge> edges = new List<Edge>();

if (element == null) return edges;

mdlKISolid_beginCurrTrans(model.MdlModelRefP());

int list = 0;
mdlKISolid_listCreate(ref list);

int body = 0;
Transform3d tMatrix = new Transform3d();
mdlKISolid_elementToBody2(ref body, ref tMatrix, element.MdlElementDescrP(false), model.MdlModelRefP(), (int)1L, 0);
mdlKISolid_applyTransform(body, ref tMatrix);
mdlKISolid_getEdgeList(list, body);

int count = 0;

mdlKISolid_listCount(ref count, list);

for (int index = 0; index < count; index++)
{
... // Some stuff
}

mdlKISolid_listDelete(list);
mdlKISolid_endCurrTrans();

...

}

PSolidCore & C#

$
0
0

In MicroStation API Documentation we found solid functions we need inside PSolidCoreAPI.h.
Very simply: what do you recommend as a best practice to access those functions programming in C#? Do we need to wrap them ourselves or some Bentley .dll already references them? 

Thank you!,


MACRO "toggle TextNodes on views" setting all opened views ON or OFF

$
0
0

Hi,

I want to switch the view setting (showing TextNodes) on all my opened views to ON or to OFF by using "one" F-Key as toggle!
Regardless of how the view setting (view TextNodes) of different views are set.

I wrote a little macro with following code, but this is not an ideal solution, because it will only work well if all views have the same view settings at the beginning.

Is there a possibility to add a "if then else" routine to this code to check if a view is ON and set it to OFF and so on....., or another solution for this problem?

Sub main
    Dim startPoint As MbePoint
    Dim point As MbePoint, point2 As MbePoint

    MbeSendCommand "powerselector deselect"                 'Global unselect any Element Selection
    MbeSendCommand "set nodes toggle"

    startPoint.x = 0.000000#                                'Coordinates in Master Units for placing Cell
    startPoint.y = 0.000000#

    point.x = startPoint.x                                  'Send a data point to select view 1
    point.y = startPoint.y
    MbeSendDataPoint point, 1%

    point.x = startPoint.x                                  'Send a data point to select view 5
    point.y = startPoint.y
    MbeSendDataPoint point, 5%

    point.x = startPoint.x                                  'Send a data point to select view 6
    point.y = startPoint.y
    MbeSendDataPoint point, 6%

    MbeSendCommand "update all"


End Sub

Thanks for your help

Regards
Raphael

[CONNECT C++] Dialog Items Access String

$
0
0

An MDL dialog item usually has an access string that connects it to a published global variable.  Here's an example taken from the delivered DialogBoxDemo...

DItem_TextRsc TEXTID_DialogDemoColor =
    {
    NOCMD, LCMD, SYNONYMID_DialogDemoColor, NOHELP, LHELPCMD,
    NOHOOK, NOARG,
    3, "%-ld", "%ld", "0", "253", NOMASK, NOCONCAT,
    TXT_Color,"dlogdemo_colorNumber"
    };

Where dlogdemo_colorNumber is the item's access string.  The item is placed in a dialog box resource like this...

{{X6, Y45, W2, 0},  Text,  TEXTID_DialogDemoColor, ON, 0, "", ""},

In some circumstances, you may want to connect the dialog item to a different published variable.  Rather than define a new item resource, one can override the access string like this...

{{X6, Y45, W2, 0},  Text, TEXTID_DialogDemoColor, ON, 0, "", "access=\"another_global_published_variable\""},

However, I'm having a problem overriding the access string for a ComboBox item...

{ { 13 * XC, GENY(2), 21 * XC, 0}, ComboBox, COMBOBOXID_Purpose, ON, ItemArgInterrogator, TXT_Purpose, "access=\"g_interrogatorVars.purpose\""},

In this case, the ComboBox continues to modify the access string defined in the item resource.  The override has no effect.

Have I done something wrong, or is it impossible to override the access string of a ComboBox?

[Connect update 6 NET API c#] PolyfaceHeader normals.

$
0
0

Hi,

I am trying to get info about mesh normals but function  ( Bentley.GeometryNET)

Normal Property

publicIEnumerable<DVector3d> Normal { get; set; }

 and function 

NormalIndex Property

publicIEnumerable<int> NormalIndex { get; }

always return zero.

            DgnModel model = Session.Instance.GetActiveDgnModel();

            Element elem = model.FindElementById(mesh_id);

            if (elem.ElementType != MSElementType.MeshHeader) return list;

            MeshHeaderElement mesh = (MeshHeaderElement)model.FindElementById(mesh_id);
            PolyfaceHeader polyface = mesh.GetMeshData();




            IEnumerable<DVector3d> vi = polyface.Normal;
            IEnumerable<int> pi = polyface.NormalIndex;

Any ideas?

regadrs

Nenad

MDL / VBA solution for permanent fill of shapes (msdFillMode)

$
0
0

Hello

Referring to my post here:

communities.bentley.com/.../view-independent-fill

regarding the permanent filling of surfaces, I come to the programmers forum and ask for help.
Jon has already posted a few variables, which let me hoping that my intention should be possible.

I want to fill areas with a permanent fill, but I do not know how that works exactly.
The suggested MDL and VBA solution ...., is that a macro to set up the basic settings for the fill to "permanent", so that all new created filled shapes will automatically be filled permanently?
Or does it only work in a way to create elements (filled shapes) also with the macro?
Or is it possible to select a non permanent filled shape and running a macro to set it to permanent fill?

I really have no idea how this should work :(

I would be very glad if someone could explain to me how permanent surfaces can be generated.

Thanks
Regards
Raphael

Microstation V8i get tag element crashes Excel macro

$
0
0

Hi,

I have been trying to write an Excel VBA macro which:

1. opens all .dgn files from selected location

2.scans for all cell elements in active model

3. builds an array with found cells

4. checks if cells have tags

5. if 4 true then builds arrays with tag elements for each cell

The code below works fine until I try to access any array with tag elements. Any operation like reading or writing of any tag element array causes Excel crash every time. Excel stops working and restarts with any other error message. The tag element arrays are created correctly because I can see them in watch window while I stop program before the "crashing" program line. There are some suspicious value in the tag element array like "Subtype- attempting to perform a non-graphical operation on graphical element". Any help would be appreciated.

Option Explicit
Dim directory As String, fileName As String

Sub ImportStart_Click() 'PROGRAM START
  ExportTexts
End Sub

Sub ExportTexts()
'On Error Resume Next
directory = GetFolder("c:\") & "\"
fileName = Dir(directory & "*.dgn")
Do While fileName <> ""
    obslugaDGN (directory & fileName)
    fileName = Dir
Loop
MsgBox "Done", vbOKOnly
End Sub

Sub obslugaDGN(plik As String)
Dim myDGN As DesignFile
Dim oAL As ApplicationObjectConnector
Set oAL = New MicroStationDGN.ApplicationObjectConnector
Set myDGN = oAL.Application.OpenDesignFile(plik, False)
Dim ee As ElementEnumerator
Dim es As ElementScanCriteria
Dim elArray() As element
Dim i, j As Integer

Set es = New ElementScanCriteria
es.ExcludeAllTypes
es.IncludeType msdElementTypeCellHeader
es.IncludeType msdElementTypeSharedCell
Set ee = ActiveModelReference.Scan(es)

elArray = ee.BuildArrayFromContents

For i = LBound(elArray) To UBound(elArray)
    If (elArray(i).HasAnyTags) Then
        Dim oTags() As TagElement
        oTags = elArray(i).GetTags()
        For j = LBound(oTags) To UBound(oTags)
            If oTags(j).TagDefinitionName = "TAG" Then  'here Excel stops working and restarts'procedure....
            End If
        Next j
    End If
Next i
myDGN.Close
Set myDGN = Nothing
Set ee = Nothing
End Sub


Function GetFolder(strPath As String) As String ' function gets folder picked by user
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
    .Title = "Select a Folder"
    .AllowMultiSelect = False
    .InitialFileName = strPath
    If .Show <> -1 Then GoTo NextCode
    sItem = .SelectedItems(1)
End With
NextCode:
GetFolder = sItem
Set fldr = Nothing
End Function

Thanks,

Darius

Viewing all 7260 articles
Browse latest View live


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