Thanks for that.
I can now select the last element (a cell) but i'm having trouble tagging it. The macro runs through the file ok - finds the text, gets the string from it, place the cell at the text origin point, but it will only tag the first piece of text, the rest remain untagged. Is this because i am not creating a unique tag set definition for each one?
Code is attached below, i have cobbled it together from a few other ones so some it may look familiar...
Function PlaceTagCell (OriginPoint as MbePoint)
MbeSendCommand "ac=rm;place cell"
MbeSendDataPoint OriginPoint
MbeSendCOmmand "null"
End Function
Function AddTagSet (strSet As String) As Integer
Dim TagSet As New MbeTagSet
TagSet.name = strSet
AddTagSet = TagSet.add = Mbe_Success
End Function
Function AddTagDeF (strSet As String, strTag As String) As Integer Dim TagDef As New MbeTagDef TagDef.setName = strSet TagDef.name = strTag AddTagDef = TagDef.add = Mbe_Success End Function
Function AttachTag (Element As MbeElement, strSet As String, strTag As String,strVal As String) As Integer Dim Tag As New MbeTag Tag.setName = strSet Tag.name = strTag Tag.value = strVal AttachTag = Element.attachTag(Tag) = Mbe_Success End Function
'///////////////////////////////////////
Sub Main
Dim endOfFile As Long
Dim elem As new MbeElement
Dim RoomString as String
dim filepos as long
dim TextOrigin as MbePoint
MbeSendCommand "mark"
strSet$ = "room-no"
strTag1$ = "room-number"
strTag2$ = "building"
strTag3$ = "floor-level"
strTag4$ = "room-name-1"
strTag5$ = "campus"
strTag6$ = "asset"
strTag7$ = "room-name-2"
' Define Tag Set and two Tags
status = AddTagSet(strSet)
status = AddTagDef(strSet,strTag1)
status = AddTagDef(strSet,strTag2)
status = AddTagDef(strSet,strTag3)
status = AddTagDef(strSet,strTag4)
status = AddTagDef(strSet,strTag5)
status = AddTagDef(strSet,strTag6)
status = AddTagDef(strSet,strTag7)
' save the End of file position
endOfFile = MbeDgnInfo.endOfFile
RoomNum=0
BeginLoop:
filePos = elem.fromFile (0)
Do While filePos >= 0
If elem.level = 56 Then
If elem.type = 17 Then
'get string from room name text
status = elem.getString(RoomString)
'get origin point of room name text
status = elem.getOrigin(TextOrigin)
'change 'read' text to different
colour and level
elem.level = 63
elem.color = 3
status = elem.rewrite
'place cell on room name text
Status=PlaceTagCell(TextOrigin)
' make the current file position the
previous End of file position
endOfFile = elem.FromFile(endOfFile)
MbeLocateElement endOfFile
RoomNum=RoomNum+1
status =
AttachTag(elem,strSet,strTag1,Str$(RoomNum))
status =
AttachTag(elem,strSet,strTag2,strTag2)
status =
AttachTag(elem,strSet,strTag3,strTag3)
status =
AttachTag(elem,strSet,strTag4,RoomString)
status =
AttachTag(elem,strSet,strTag5,strTag5)
status =
AttachTag(elem,strSet,strTag6,strTag6)
status =
AttachTag(elem,strSet,strTag7,strTag7)
'print filepos
goto beginloop
End If
End If
filePos = elem.fromFile (filePos + elem.fileSize)
Loop
End Sub