VBA SetValue method for PropertyHandler in AECOsim BD

[AECOsim V8i SELECTseries 6 VBA]

[AECOsim CONNECT VBA]

Hello everyone,

To continue previous discussion ( .../programming/microstation_programming/f/microstation-programming---forum/184516/vba-propertyhandler-setvalue-method )

with new question about SetValue method...

So, I have a simple code for  porperties changing:

Sub change_prop()
    Dim oTarget As Element
    Dim OPH As PropertyHandler
    Dim a As DLong
    
    a = DLongFromString("726841")
    Set oTarget = ActiveDesignFile.GetElementByID(a)
    Set OPH = CreatePropertyHandler(oTarget)
        OPH.SelectByAccessString ("StructProp__x002f____x0040__StructCode")
        Debug.Print OPH.GetValue
        OPH.SetValue ("Architect")
        Debug.Print OPH.GetValue
        
'oTarget.Rewrite
'oTarget.Redraw
End Sub

Here is element in my model and its properties:

Property "Code" have value "Previous Example". In vba code i change the property by its name (name is long, but its right), a new value should be "Arcitect".

So, the problem is that the value is not saved after "End Sub".

What i can see in Immediate window after code was started TWO times:

Value changes while code is running, but have previous value after Sub.

Rewrite, Redraw methods do not change the result.

Everything is ok with changing Line weights, layers for example,  but not this "string" properties.

Its strange, that new value does not applied.

May be some settings of added properties for catalog elements should be corrected? Or may be code is not complete?

  • Hi Sergey,

    Rewrite, Redraw methods do not change the result.

    There is no reason to use Redraw method anywhere than in Dynamic (in primitive or location tool).

    Also Rewrite is not necessay, because PropertyHandler saves the changes immediately (whereas element modification, e.g. its geometry, has to be written do a file explictly).

    Its strange, that new value does not applied.

    I think it's not strange, but feature. This issue should be forwarded directly to building programming group (maybe would be so kind to do it?), because there is no such definition "all properties are writeable", some can be read-only and it depends both on implementation source application itself (AECOsim BD, not MicroStation itself in this case) and how VBA porperty handler is implemented.

    With regards,

      Jan

  • Hi Jan,

    Thak you for answer

    some can be read-only

    There is some other properties for element ("Structural data") and this properties group exists by default for Structural elements in AECOsim.

    If I try to change it the same way,thats what i get:

    I can see a current value, and have a "Read-only" message for SetValue. According to this, property "Code" is not read-only.

    It would be very useful for us to change properties by VBA, many advantages for usual rutine work. I also made a service request with link to this topic. Hope to get a solution

  • I can see a current value, and have a "Read-only" message for SetValue. According to this, property "Code" is not read-only.

    It's something different: When a property is displayed as read-only (dimmed), it means it's defined in EC schema as read-only and MicroStation is able to recognize this configuration and to display the property value as dimmed.

    But, based on some discussions in the past, it seems sometimes, probably because of implementation, the poperty can be changed manually (in MicroStation dialog), but not using PropertyHandler.

    Hope to get a solution

    I am afraid there will be no simple solution available, even when the source of the problem will be identified. This behaviour is often caused by the implementation itself, so to change it is a long-term activity. But there is always a hope for some workaround.

    With regards,

      Jan