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
Where did you find "CreatePropertyHandler" ? That's not a plain Microstation VBA method (MicroStationVBA.chm or vba_concept.chm search)
Is it a Bentley Map VBA extension?
Regards
Frank
since 1985: GIS, CAD, Engineering (Civil) Senior Consultant : [Autodesk Civil 3D , Esri ArcGIS, VertiGIS: in previous days : Bentley MS V4 - V8i, GeoGraphics, Bentley Map V8i, InRoads, HHK Geograf, IBr DAVID] : Dev: [C, C++, .NET, Java, SQL, FORTRAN, UML][direct quote by: http://en.wikipedia.org/wiki/Helmut_Schmidt]: "Wer Kritik übel nimmt, hat etwas zu verbergen"Wer Grammatik- und/oder Rechtschreibfehler findet, der darf sie behalten :-)
Unknown said:Where did you find "CreatePropertyHandler" ?
Regards, Jon Summers LA Solutions
I used selectionset example from VBA and added propertyhandler from this example - communities.bentley.com/.../120502.aspx
It works great but only on annotation cells.
Now it is question how to convert existing normal cell to annotation cell without using cell library. How annotation cells are different from normal cells? I suppose I need to add some fancy Property or what?
Thanks Jon, I feel a little bit lost!
Sorry my fault, to many Microstation Versions on my PC!You're right MicroStationVBA.chm from 16 Oct 2008 does have that info!
Reviving the old code. Still I am stuck. Trying to wrap MDL function for adding isAnnotation but get error "Bad DLL calling convention".
Declare Function mdlCell_setIsAnnotation Lib "ustation.dll" ( _ ByVal edP1 As Long, _ ByVal isAnnotation As Boolean) As Long ' --------------------------------------------------------------------- ' SetIsAnnotation ' Wrapper around MDL function mdlCell_setIsAnnotation ' Returns: Boolean True if success Public Function SetIsAnnotation(ByVal TheElement As Element, isAnotation As Boolean) As Long If TheElement Is Nothing Then Err.Raise msdErrorBadElement, "MDL examples", "The Element is Nothing" Exit Function End If SetIsAnnotation = 0 <> mdlCell_setIsAnnotation( _ TheElement.MdlElementDescrP(False), True) End Function Public Sub getSelectionSet() Dim oElEnum As ElementEnumerator Dim oEl As Element Dim propHand As PropertyHandler Dim accessString() As String Set oElEnum = ActiveModelReference.GetSelectedElements oElEnum.Reset While oElEnum.MoveNext Set oEl = oElEnum.Current Set propHand = CreatePropertyHandler(oEl) 'accessString = propHand.GetAccessStrings propHand.SelectByAccessString "AnnotationPurpose" If propHand.GetValue = True Then propHand.SelectByAccessString "IsAnnotation" propHand.SetValue True oEl.Redraw msdDrawingModeNormal oEl.Rewrite Else status = SetIsAnnotation(oEl, True) 'mdlCell_setIsAnnotation (MSElementDescrP cellEdP, BoolInt isAnnotation) End If Wend End Sub
Oto said:Trying to wrap MDL function for adding isAnnotation
I can't see mdlCell_setIsAnnotation in either the MicroStation V8 API or the CONNECT API. Where did you find it?
mdlCell_setIsAnnotation
There's always a hazard when using an undocumented function, especially from another language. However, your declaration:
Declare Function mdlCell_setIsAnnotation Lib "ustation.dll" ( _ ByVal edP1 As Long, _ ByVal isAnnotation As Boolean) As Long
Specifies a Boolean that isn't. Try this declaration for MicroStation V8:
Boolean
Declare Function mdlCell_setIsAnnotation Lib "ustation.dll" ( _ ByVal edP1 As Long, _ ByVal isAnnotation As Long) As Long
It is undocumented but widely used:https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/129566/connect-c-making-a-cell-an-annotation-cellhttps://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/77907/change-a-cell-to-be-is-annotation-in-mdl/213185#213185
Are you revieving code because of migration to CONNECT Edition or you are still on V8i?
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point