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

[MSTN V8i] [C#]Judge four points on a plane?

$
0
0

Take four points at any point. I want to judge whether it is on a plane.My MicroStation version is v8i ss3, Visual Studio  version is  vs2015 Pro.If there is any way to provide it to me, I am very grateful.

  


autorun run external macro

$
0
0

How is it possible to run a macro in  another .mvba from the Autorun

I have added some commands: in the Autorun

CadInputQueue.SendCommand "View Off All" 'Turn off all views
CadInputQueue.SendCommand "View On 1" 'Turn View 1 on
CadInputQueue.SendCommand "Window Tile" 'Resize View 1 to fit screen
CadInputQueue.SendCommand "Fit All" 'Start Fit All command
CadInputQueue.SendCommand "Selview 1" 'Apply to View 1

These all work, what I wanted to add was a Macro from Name.mvba and I know it is Module6.SetDefaults        

I can run the macro from the key-in command vba run SetDefaults and it works fine, but I was hoping to add it to the autorun

and eliminate extra commands

【MSTN】【C#】【V8i】Extract cellelement based on the shape of an element

$
0
0

I drew a CellElement, as shown in the figure,

I want to turn it into another shape. This shape is an element created by the CreateShapeElement1 method in the VBA document.

Is there any way to realize it, any suggestions would be grateful?

[CONNECT C# .NET] How to associate an ItemType to a parametric model and then create a variation associated with the ItemType?

$
0
0

Hello,

I am using OpenBuildings CONNECT Update 5, I think the version is 10.00.14.18. 10.05.00.49 (Corrected).  I am using the MicroStation Update 12 SDK.

I am trying to create a variation (parameter set) in a model but I want to associate the variables with an Item Type as shown in the attached dialog box rather than using local variables.

From what I can piece together from the SDK documentation and the parametric modelling examples provided in the SDK, the general steps are:

  1. Get a reference to the parameter definitions for the model
  2. Create an instance of the ItemType
  3. Call SetDomainParameters to associate the item type instance to the parameter definitions
  4. Get the DefinitionModelHandler for the model
  5. Create a parameter set using the DefinitionModelHandler
  6. Get the property values as IDgnECInstance
  7. Get each parameter definition and set its value

So I tried this code:

EditParameterDefinitions defs = EditParameterDefinitions.GetForModel(dgnModel);
ItemTypeLibrary itemTypeLibrary = ItemTypeLibrary.FindByName(LIB_NAME, dgnModel.GetDgnFile());
ItemType itemType = itemTypeLibrary.GetItemTypeByName(ITEMTYPE_NAME);
Bentley.ECObjects.Instance.IECInstance ecProperties = itemType.CreateTemplateInstance();
defs.SetDomainParameters(ecProperties);
// **** stuck here ****
// --> always returns ParameterStatus.InvalidParameterValues

// in a separate method after the domain class has been attached to the model
var handler = DgnComponentDefinitionHandler.GetForModel(dgnModel).DefinitionModelHandler;
EditParameterDefinitions defs = EditParameterDefinitions.GetForModel(dgnModel);
ParameterSet paramSet = handler.CreateParameterSet("variationName", null, null);
IDgnECInstance propertyValues = paramSet.Properties as IDgnECInstance;
// for each relevant parameter value (e.g. "SectionDepth")
ParameterDefinition paramDef = defs.FindByLabel(parameterName);
if (paramDef != null)
{
    IECPropertyValue propertyValue = propertyValues.FindPropertyValue(paramDef.AccessString, false, false, false, true);
    propertyValue.NativeValue = itemValue;  // 
}

When I run the debugger and test the variables in the immediate window, I obtain the following results:

defs
{Bentley.DgnPlatformNET.EditParameterDefinitions}
    DependencyRoot: {Bentley.DgnPlatformNET.Elements.ExtendedNonGraphicsElement}
    DomainClass: null
    HostModel: {Bentley.DgnPlatformNET.DgnModel}
    LocalParameterCount: 0
    Properties: {{DgnActiveParameters(:ECDA00000001:1595170100)}}

itemType
{Bentley.DgnPlatformNET.ItemType}
    ECClass: ECClass: "Structure__x0020__Attachment", Schema="DgnCustomItemTypes_Railway__x0020__Overhead__x0020__Wiring.01.00", IsDomainClass=true, IsCustomAttribute=false, IsStruct=false, BaseClasses[0]={System.NullReferenceException: Object reference not set to an instance of an object.
   at <>x.<>m0(ECClass <>4__this)}
    Guid: 2
    Id: 2
    InternalName: "Structure__x0020__Attachment"
    IsCustomType: false
    IsIdentifyingItem: false
    LabelProperty: null
    Library: {Bentley.DgnPlatformNET.ItemTypeLibrary}
    Name: "Structure Attachment"
    PropertyCount: 6
    Results View: Expanding the Results View will enumerate the IEnumerable

itemType.ToArray()
{Bentley.DgnPlatformNET.CustomProperty[6]}
    [0]: {Bentley.DgnPlatformNET.CustomProperty}
    [1]: {Bentley.DgnPlatformNET.CustomProperty}
    [2]: {Bentley.DgnPlatformNET.CustomProperty}
    [3]: {Bentley.DgnPlatformNET.CustomProperty}
    [4]: {Bentley.DgnPlatformNET.CustomProperty}
    [5]: {Bentley.DgnPlatformNET.CustomProperty}

itemType.ToArray()[2]
{Bentley.DgnPlatformNET.CustomProperty}
    Container: {Bentley.DgnPlatformNET.ItemType}
    CustomType: null
    DefaultValue: 0
    DefaultValueExpression: "0.0"
    Guid: 3145730
    Id: 3145728
    InternalName: "SectionDepth"
    IsArray: false
    Library: {Bentley.DgnPlatformNET.ItemTypeLibrary}
    Name: "SectionDepth"
    PickListName: null
    Priority: 2147418107
    SupportsCustomType: true
    SupportsUnits: true
    Type: Double
    TypeId: 2
    Units: {Bentley.DgnPlatformNET.DgnECUnit}

ecProperties
{{Structure__x0020__Attachment()}}
    ClassDefinition: ECClass: "Structure__x0020__Attachment", Schema="DgnCustomItemTypes_Railway__x0020__Overhead__x0020__Wiring.01.00", IsDomainClass=true, IsCustomAttribute=false, IsStruct=false, BaseClasses[0]={System.NullReferenceException: Object reference not set to an instance of an object.
   at <>x.<>m0(ECClass <>4__this)}
    ClassLayoutChecksum: 1243618337
    ContainsValues: true
    ECDValueContainer: {Bentley.ECObjects.Instance.ECDMemoryBuffer}
    Enabler: null
    ExtendedData: {Bentley.Collections.EmptyReadOnlyDictionary<object>}
    ExtendedDataValueSetter: {Bentley.Collections.OptimizedDictionary<object>}
    Instance: {{Structure__x0020__Attachment()}}
    InstanceId: ""
    IsHiddenInstance: false
    IsPartiallyLoaded: false
    IsReadOnly: false
    MemoryBuffer: {Bentley.ECObjects.Instance.ECDMemoryBuffer}
    NumBitsPerProperty: 2
    PerPropertyFlags: {Bentley.ECObjects.Instance.PerPropertyFlagsHolder}
    PerPropertyFlagsCount: 1
    ReferenceObject: null
    UsageBitmask: 0
    _ECArrayCountChanged: null
    _ECPropertyValueChanged: null
    _ECReferenceObjectChanged: null
    m_instanceId: ""
    Results View: Expanding the Results View will enumerate the IEnumerable

ecProperties.ToArray()
{Bentley.ECObjects.Instance.IECPropertyValue[6]}
    [0]: {Bentley.ECObjects.Instance.ECDCalculatedDoubleValue}
    [1]: {Bentley.ECObjects.Instance.ECDCalculatedIntegerValue}
    [2]: {Bentley.ECObjects.Instance.ECDCalculatedDoubleValue}
    [3]: {Bentley.ECObjects.Instance.ECDCalculatedStringValue}
    [4]: {Bentley.ECObjects.Instance.ECDCalculatedStringValue}
    [5]: {Bentley.ECObjects.Instance.ECDCalculatedStringValue}

ecProperties.ToArray()[2]
{Bentley.ECObjects.Instance.ECDCalculatedDoubleValue}
    AccessString: "SectionWidth"
    ArrayIndex: -1
    BaseECDInstance: {{Structure__x0020__Attachment()}}
    ContainedValues: null
    Container: {{Structure__x0020__Attachment()}}
    DoubleValue: 0
    ECDValueContainer: {Bentley.ECObjects.Instance.ECDMemoryBuffer}
    Evaluator: {Bentley.ECObjects.Schema.CalculatedECPropertyEvaluator}
    GeometryValue: null
    Instance: {{Structure__x0020__Attachment()}}
    IntValue: 0
    InternalValue: 0
    IsAlwaysNull: false
    IsArray: false
    IsNull: false
    IsPrimitive: true
    IsReadOnly: false
    IsStruct: false
    Layout: {SectionWidth double offset=16 nullflagsOffset=0, nullflagsBitmask=00000004}
    LongValue: 0
    NativeAccessString: "SectionWidth"
    NativeValue: 0
    ParentPropertyValue: null
    Property: ECProperty: "SectionWidth", Type="double", IsReadOnly=false
    State: Calculated
    StringValue: "0"
    Type: {Bentley.ECObjects.Schema.ECDoubleType}
    XmlStringValue: "0"

As I am not very familiar with the ECObjects namespace and parametric modelling objects, I am not sure if I have called the correct method or there is another step missing.

Can someone advise:

  1. How I can attach the item type to the parameter set and then
  2. (Pre-empting my next question) how I can create a variation and set the item type parameter values for the new variation?

Any help would be greatly appreciated.

Regards,

Trevor

Keyin or VBA for left click accept

$
0
0

Hello,

I am trying to automate several different processes through Keyins and VBA. I am not a programmer, just trying to make things work through Keyins and recording VBA macros. I have manged to edit some of the macros to get things done. The problem we keep running into is how do automate the left click in the background to accept a command?

For instance, If through a keyin I select a cell and want to adjust the scale to the active scale, I have to left click in the background to accept the change. When I tried recording the process to create a VBA macro it does not show us. There must be a simple solution.

Any help is greatly appreciated. 

Thank you,

Robert

V8i (SELECT series 3) 08.11.09.459

[U12 C++] AccudDraw.SetContext() and AccuDrawFlags

$
0
0

Can someone provide a "mapping" between the parameters of AccuDraw.SetContext() and the AccuDrawFlags? The example only seems to use "ACCUDRAW_SetXAxis". For example, If I wish to use ACCUDRAW_UpdateRotation, which parameter(s) of AccuDraw.SetConext() should I use? The header file provides no clues.....

enum AccuDrawFlags
    {
    ACCUDRAW_SetModePolar       = (1),
    ACCUDRAW_SetModeRect        = (1<<1),
    ACCUDRAW_SetOrigin          = (1<<2),
    ACCUDRAW_FixedOrigin        = (1<<3),
    ACCUDRAW_SetRMatrix         = (1<<4),
    ACCUDRAW_SetXAxis           = (1<<5),
    ACCUDRAW_SetNormal          = (1<<6),
    ACCUDRAW_SetDistance        = (1<<7),
    ACCUDRAW_LockDistance       = (1<<8),
    ACCUDRAW_Lock_X             = (1<<9),
    ACCUDRAW_Lock_Y             = (1<<10),
    ACCUDRAW_Lock_Z             = (1<<11),
    ACCUDRAW_Disable            = (1<<12),
    ACCUDRAW_Set3dMatrix        = (1<<13),
    ACCUDRAW_OrientDefault      = (1<<14),
    ACCUDRAW_SetFocus           = (1<<15),
    ACCUDRAW_Delay              = (1<<16),
    ACCUDRAW_OrientACS          = (1<<17),
    ACCUDRAW_SetXAxis2          = (1<<18),
    ACCUDRAW_LockAngle          = (1<<19),
    ACCUDRAW_AllowStartInLocate = (1<<20),
    ACCUDRAW_AlwaysSetOrigin    = ((1<<21)|ACCUDRAW_SetOrigin),
    ACCUDRAW_RedrawCompass      = (1<<22),
    ACCUDRAW_UpdateRotation     = (1<<23),
    };

How to change Workspace and Workset to match file

$
0
0

On the file open dialog of Connect Edition user can set the workspace and workset and open the selected file.

Does somebody know how can do it in C# Code.

Need assistance tracking down V8i MDL message center error message "MDL detected an illegal opocode"

$
0
0

Hello Everyone,

I am moving an MDL application to V8i, and working to test the functionality.

Code causes MDL application to unload when command reaches the restart.

Message before the unload in the message center is "MDL detected an illegal opcode."

Have removed the restart and the issue still happens. When stepping through the code there does not seem to be any issue.

Have checked memory allocation and it is stable. Looked at the memory copy commands and nothing noticed.

Are there any other items I can check?

Thanks

Peter


[CONNECT C++] Why isn't Picklist.GetName const?

$
0
0

Picklist class has method GetName() that is non-const.  Why?

It means we can't iterate a Picklist like this …

for (PickListLibrary::const_iterator pickList = lib.begin (); pickList != lib.end (); ++pickList)
{
  // Won't compile: we have a const iterator and a non-const method// do something with pickList->GetName ()
}

Instead, we must use the non-const form of the iterator …

for (PickListLibrary::iterator pickList = lib.begin (); pickList != lib.end (); ++pickList)
{
  //  Compiles OK// do something with pickList->GetName ()
}

If this question doesn't make sense to you, visit this site.

[CONNECT C++] GetPickListLibFromDgn fails

$
0
0

These two lines of code build OK but cause an Internal Error: Access Violation at runtime...

PickListLibrary		lib;
PickListLibrary::GetPickListLibFromDgn (ISessionMgr::GetActiveDgnFile (), lib);

struct PickListLibrary : public RefCountedBase tells us that PickListLibrary is a reference-counted class.  I would expect there to be a static public Create() method to get a PickListLibraryPtr.  However, there's no MakeAbstract() or other means to make PickListLibrary abstract.

What have I missed?

[CONNECT C++] PickListExistsInDgn vs. CanFindPickListByNameInDgn

$
0
0
PickListLibrary::PickListExistsInDgn() and PickListLibrary::CanFindPickListByNameInDgn() appear to provide the same functionality.   What is the difference?

[CONNECT U12] Monitor EC data change best practice?

$
0
0

Hi,

this my question is more about best practice, not specifically targeted to C++ or C#. C# is preferred in my current project, but when the solution will be available in C++ only, no problem.

Situation: There is an element with custom EC data attached. The data are available in Properties (Element Information) dialog and can be modified by a user. Such change is saved to persistent storage (DGN V8 file) by MicroStation automatically.

Question: Is it possible and what is recommended approch to monitor such change to be able to react on the change (e.g. to modify the element size/shape/etc.)?

I have not done any testing or research yet, but I can imagine that XAttribute changed event is fired when EC data are changed, but it seems to me a bit complicated (go through the whole path from XAttribute, test whether it's EC data or not and to what element it belongs). Maybe there is some other solution available, e.g. to monitor EC data particularly or to hook system responsible for rendering EC data in GUI?

With regards,

  Jan

Step by step guide for creating MicroStation Addins in C#

$
0
0

Just wanted to make a post to hopefully help some people.

I have created a guide linked below, that walks you through how to set up a visual studio project to be used as an Addin within MicroStation.

hopefully it will save people from the struggles i went through to figure out how to set one up.

Rewrite subelement of complex element after changing scale

$
0
0

We need to change the scale of the complex element (defined by the lines). Our idea works fine with non complex element, where we apply LineStyle with new scale value.

With the complex element, we cannot use the mdlElmdscr_rewrite method - it causes error 69645.

How to rescale child ElementDesc in complex element in C++?

USING VBA TO EXTRACT TAG INFO FROM FILE TO DATABASE USING MICROSOFT ACCESS

$
0
0

My client has a title block cell with tags in it.  We have built a database from Microsoft Access. (I have heard it is at EOL).  Until we go to a new database I would like to extract the tag information and import it to the Access database.

I am not a coder and not well versed in VBA.  Can anyone point me in the right direction?  We had a routine that worked in V8i but it fails to execute in Connect (10.10.00.23)

(Cannot upgrade to the latest version of Connect due to client constraints.)


[CONNECT C++] CurveCurve::CollectFilletArcs()

$
0
0

Trying to get a fillet generated between 2 lines with a common vertex, The returned FilletDetail <bvector> always has a size of zero:

		// create my "fillet" arc
		CurveVectorPtr						previousCurve = ICurvePathQuery::ElementToCurveVector(eeh1);
		CurveVectorPtr						currentCurve = ICurvePathQuery::ElementToCurveVector(eeh2);
		ICurvePrimitivePtr					&previousSegment = previousCurve->front();
		ICurvePrimitivePtr					&currentSegment = previousCurve->front();

		bvector<CurveCurve::FilletDetail>			arcs;
		CurveCurve::CollectFilletArcs(*previousSegment,*currentSegment,SRS::SRSConvert::InchToUOR(1.5), false, arcs);

		wprintf(L"%d arcs \n",arcs.size());

I have also used 'true' to allow the extension of the lines, but still, it seems no arcs (fillets) are created...

Bruce

[CONNECT] PickList values

$
0
0

A PickList contains a list of PickListValuePickList.AddValue takes a string.  PickListValue.Value is a getter/setter that takes a string.

So what is it that PickList.HasIntegerValues and PickList.HasDoubleValues tell us? Do those properties check that each member of a PickList contains a string that can be converted to an Integer or Double?  Or, is something else going on?

Connect app x86/x64 and compatible Visual Studio version for external DLL

$
0
0
Hi,
I started to migrate a large number of lines of code (.mc) in .cpp using CONNECT SDK V.10.11.00.42
I am reading the documentation and I would like to be sure that I have understood certain things correctly
1) Apps cannot be compiled in x86 version (only the x64 version is possible)
2) I have call from a new (cpp) connect app a function stored into an external (cpp) DLL. The external DLL is compiled with Visual Studio 2015 but if i compile it with Visual Studio 2010 the code seems to run correctly.
Can i use external code compiled with Visual Studio 2010 though the CONNECT SDK require Visual Studio 2015?
Thanks and Best Regards
Marco

Partial Delete via VBA

$
0
0

Hi,

The little hair I have left is turning grey in frustration.

I am running MicroStation V8i and try to automate some procedures.

I am trying to perform a partialdelete function on an arc, but the function returns "Nothing" in the return element. 

For testing I created an arc running through (5,5,0) just to make things easy

The routine is part of a much larger program that draws Coplex Chains from different elements, but this little bit is not working.

Anyone seeing something I can't see?

Sub PartDel()
Dim scancrit As ElementScanCriteria
Dim elemenum As ElementEnumerator
Dim point(2) As Point3d
Dim elm1 As Element
Dim elm2 As Element
Dim archelem As Element
Dim dist As Double

point(0).x = 0
point(0).Y = 0
point(0).Z = 0
Set scancrit = New ElementScanCriteria
scancrit.ExcludeNonGraphical
scancrit.IncludeType msdElementTypeArc
Set elemenum = ActiveModelReference.Scan(scancrit)
Do While elemenum.MoveNext
  Set archelem = elemenum.current
  point(1) = archelem.AsArcElement.StartPoint
  point(2).x = 5                                        ' this is a known point (variable)
  point(2).Y = 5                                        ' It shall be part of the parameters
  point(2).Z = 0                                        ' to this routine
  archelem.AsArcElement.PartialDelete elm1, elm2, point(1), point(2), point(0), 1    ' This return "Nothing" in elm1
  ActiveModelReference.AddElement elm1
Loop
End Sub

Basic to VBA Macro Conversion

$
0
0

I have what should work in VBA but if the hilight color and selection color are the same on a  new markup have had both yellow before also.

Anyway if they are both the same the following VBA fails, it only changes the highlight color to the same new color. I was asking for example

Cyan, Magenta ... I even tried scrip files and they also work as long as the two starting colors are not  the same. When opening a new markup

I had a button to change the two settings and only works if the two colors are different at the onset ?

CadInputQueue.SendKeyin "set hilite Yellow"
CadInputQueue.SendKeyin "mdl keyin calculat calc tcb->selectionHiliteColor=5"
CadInputQueue.SendKeyin "m,ms Yellow & Magenta"

the text on the screen says Yellow Magenta, but it will not change the selection set color

Is the results of the above, If I manually change the Gray and Gray to  say gray and blue

 Run the same macro above 

 it works, I cannot control what comes to me, but I do not like gray, gray or the yellow, yellow.

any help ?   Even the following script file works if the starting two colors are not the same

set hilite Green
mdl keyin calculat calc tcb->selectionHiliteColor=5
mdl keyin calculat calc tcb->selectionHiliteOverride=5
m,msGreen & Magenta

hoping I do not get taken to the wood shed on this question. 

Viewing all 4331 articles
Browse latest View live


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