I created this macro to add annotation scale to selected cells but it seems to work only for "Annotation cells". How to convert also normal cells to annotation cells on-the-fly?
Public Sub getSelectionSet() Dim oElEnum As ElementEnumerator Dim oEl As Element Dim propHand As PropertyHandler Set oElEnum = ActiveModelReference.GetSelectedElements oElEnum.Reset While oElEnum.MoveNext Set oEl = oElEnum.Current Set propHand = CreatePropertyHandler(oEl)propHand.SelectByAccessString "AnnotationPurpose"If propHand.GetValue = True ThenpropHand.SelectByAccessString "IsAnnotation"propHand.SetValue True oEl.Redraw msdDrawingModeNormal oEl.Rewrite End If WendEnd Sub
I think the problem is here that VBA doesn't use cdecl calls so this function is not available in VBA.https://communities.bentley.com/products/programming/microstation_programming/f/archived-microstation-v8i-programming-forum/54936/vba2mdl/129830#129830So I have to use the similar GetCExpression method in VBA also.
Oto said:So I have to use the similar GetCExpression method in VBA also.
I think you are correct that the function is not accessible directly from VBA.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Now this function using GetCExpressionValue works. But next problem is that normal cells which are updated using MDL function do not react later to isAnnotation property. It still shows that cell is normal cell but with Annotation Purpose= true.
It doesn't allow to change isAnnotation property until file is closed and repoened so Microstation updates the status of normal cell to annotation cell. How to force this refresh without reopening file?
Public Function SetIsAnnotation(ByVal TheElement As Element, isAnotation As Long) As Long If TheElement Is Nothing Then Err.Raise msdErrorBadElement, "MDL examples", "The Element is Nothing" Exit Function End If 'mdlCell_setIsAnnotation (MSElementDescrP cellEdP, BoolInt isAnnotation) SetIsAnnotation = 0 <> GetCExpressionValue("mdlCell_setIsAnnotation (" & _ TheElement.MdlElementDescrP() & "," & _ isAnotation & ")") TheElement.Rewrite End Function
Also question I would try to wrap alternative way of setting IsAnnotation flag using VBA. What would be correct syntax to achieve that?SetCExpressionValue "TheElement.MdlElementDescrP()->el.cell_2d.flags.isAnnotation", isAnnotationstatus = GetCExpressionValue("TheElement.MdlElementDescrP()->el.cell_2d.flags.isAnnotation=TRUE")See this: https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/93972/convert-cell-to-annotation-cell-without-can-be-used-as-annotation-flag-being-set/274437#274437
Any idea how to use another undocumented function mdlCell_setAnnotationScale? This is needed otherwise cells still shows as normal cell until file is reopened.
Oto said:status = GetCExpressionValue("TheElement.MdlElementDescrP()->el.cell_2d.flags.isAnnotation=TRUE")
TRUE probably doesn't work. Try this:
status = GetCExpressionValue("TheElement.MdlElementDescrP()->el.cell_2d.flags.isAnnotation != 0")
Regards, Jon Summers LA Solutions
Sorry if I missed something prior, but I see in VBA for a given ModelReference the CanBePlacedAsCell property is a read/write parameter, that may allow you to set a normal cell to an annotation cell. Underneath the hood the property performs some validation and calls mdlModelRef_getModelFlag/mdlModelRef_setModelFlag (Related Flags: MODELFLAG_IS_ANNOTATION_CELL, MODELFLAG_USE_ANNOTATION_SCALE, MODELFLAG_NOT_IN_CELL_LIST - if true make false).
If neither set of options performs the task needed please let me know.
HTH,Bob
But I need to convert already placed cells in file to annotation cells. Replace cells tool does this when replacing with new cell but using update method the problem is the same as using VBA, the cell is not correctly converted or in case of VBA not directly possible. That is why need to use MDL functions. How to set isannotation flag for cell and also set the annotation scale so no need to reload file?
That is always has been problem of MicroStation that converting between element types is very troublesome. How to use new element types and get benefit of new MicroStation features if there are no standard tools to do that. Of course starting from scratch it works but what if I reference files where there are old cells or the scales for annotation are wrong.
Still got error "Symbol "TheElement" not defined.
update_dgnlib_vba.mvba