Object selection in Macros

Status
Not open for further replies.

Rolf Alber

Usenet Archive
Joined
Dec 12, 2001
Messages
3
Reaction score
0
Hello !

Concerning MicroStation-Basic I have a question which sounds quite simple, but brought some difficulties to me:

Is it possible to select an element without doing a
MbeSendCommand "CHOOSE ELEMENT "

and afterwards passing a datapoint which hopefully is near enough to the desired object ?

P. ex. I would like the last drawn Item to be selected (without specifically knowing where this object was placed).

Any help is greatly appreciated.

Rolf Alber
 
Rolf what do you wish to do if it is to select an element interactively then use the following example which lets you select an element then it moves it by a factor of 200. Note due to the element being captured you can do several forms of manipulation to it, for example change its colour or style, scale it or delete it.

#----------------------------------------------------------- Sub Main

Dim filepos as Long
Dim elem as New MbeElement
Dim continueLocate as Integer

MbeSendCommand "NOECHO"
MbeWritePrompt "Select Element"
MbeStartLocate 0, 0, 0, continueLocate
accepted = FALSE

While NOT accepted

MbeStartLocate
MbeWritePrompt "Select element..."
MbeGetInput MBE_DataPointInput, _
MBE_ResetInput, _
MBE_CommandInput, _
MBE_KeyInInput

Select Case MbeState.InputType
Case MBE_CommandInput
MbeSendLastInput
Exit Sub
Case MBE_KeyinInput
MbeSendLastInput
Exit Sub
End Select

MbeSendLastInput
filePos = elem.fromLocate

While MbeState.CmdResult = MBE_AcceptQuery AND _ NOT accepted

MbeWritePrompt "Accept/Reject"
MbeGetInput MBE_DataPointInput, _
MBE_ResetInput, _
MBE_CommandInput, _
MBE_KeyInInput

MbeSendLastInput

Select Case MbeState.InputType
Case MBE_ResetInput
filePos = elem.fromLocate
Case MBE_DataPointInput
accepted = TRUE
Case MBE_CommandInput
MbeSendLastInput
Exit Sub
Case MBE_KeyinInput
MbeSendLastInput
Exit Sub
End Select
Wend
Wend
continueLocate = FALSE

MbeSendCommand "move element"
MbeLocateElement filepos
MbeSendCommand "dx=200,0"
MbeSendReset

End Sub
#----------------------------------------------------------- I hope this helps

Regards

Wayne Marsh

"Rolf Alber" wrote:
Hello !

Concerning MicroStation-Basic I have a question which sounds quite simple, but brought some difficulties to me:

Is it possible to select an element without doing a
MbeSendCommand "CHOOSE ELEMENT "

and afterwards passing a datapoint which hopefully is near enough to the desired object ?

P. ex. I would like the last drawn Item to be selected (without specifically ...
 
Posting to comp.cad.microstation.programming is a better bet than here, but with that said, you should be able to use the same approach that user command programmers use to use, which is:

Find the end of file
place another element
look for the element where the old end of file was.

There may even be some sample macros that work on this principle.

I will admit that the locate an element interactively methodology of basic macros seems way more complicated than it used to be in a user command.

HTH

"Rolf Alber" wrote:
Hello !

Concerning MicroStation-Basic I have a question which sounds quite simple, but brought some difficulties to me:

Is it possible to select an element without doing a
MbeSendCommand "CHOOSE ELEMENT "

and afterwards passing a datapoint which hopefully is near enough to the desired object ?

P. ex. I would like the last drawn Item to be selected (without specifically ...
 
Hi Rolf,
This little macro hilites the last element in the active design file:

Sub Main
Dim element As New MbeElement
Dim filePos As Long
Dim lastPos As Long

'start with first element in file
filePos = element.fromFile (0)

'do until EOF (when filePos = -1)
Do While filePos >= 0
'store the current element position:
lastPos = filePos

'calculate file position of next element:
filePos = element.fromFile (filePos + element.fileSize, 0)
Loop

'set the file position to the last valid element from lastPos:
filePos = element.fromFile (lastPos, 0)

'hilite the element:
element.display MBE_Hilite
End Sub

Instead of hiliting, you could provide additional processing.

HTH,
Simon

Rolf Alber wrote:
Hello !

Concerning MicroStation-Basic I have a question which sounds quite simple, but brought some difficulties to me:

Is it possible to select an element without doing a
MbeSendCommand "CHOOSE ELEMENT "

and afterwards passing a datapoint which hopefully is near enough to the desired object ?

P. ex. I would like the last drawn Item to be selected (without specifically ...
 
Status
Not open for further replies.

Latest threads

Back
Top