Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

extracting saved view with mbebasic?

26 views
Skip to first unread message

Harry Stegeman

unread,
Dec 21, 2000, 6:34:40 PM12/21/00
to
Hello all,

Does anybody know it is possible to extract or
scan for the definitions of saved views in a
design file?

I know about the mdl routine svinfo.mc, I would
like to do this in basic.

Regards,

Harry Stegeman


Simon Wurster

unread,
Dec 21, 2000, 6:39:17 PM12/21/00
to
Hi Harry,
Alan Williams (whatever happened to him?) posted this gem a while back (thanks
Alan!):

The "named_view_type5" is defined in mselems.h (to be found in the mdl\include
directory). I may be wrong but I don't think this is published to Mbe Basic. The
following code is rather "nasty" but it will return the names of all saved views
in a drawing.

HTH

Alan Williams Email al...@awol.demon.co.uk
al.wi...@taywood.co.uk

Sub Main ()
Dim Element As New MbeElement
Dim FilePos As Long
Dim C1 As Double
Dim C2 As Double
Dim S As String

FilePos = Element.fromfile(0)

While FilePos >= Mbe_success
If Element.type = 5 And Element.level = 3 then
Element.publish "elem"
C1 = MbeCExpressionLong
("elem.currentPosition->el.line_string_2d.vertice[16].y")
If C1 < 0 Then C1 = C1 + 2^32
C2 = MbeCExpressionLong
("elem.currentPosition->el.line_string_2d.vertice[17].x")
If C2 < 0 Then C2 = C2 + 2^32
S = Radix (C1 \ 16^4) & Radix(C2 Mod 16^4)
Print S
End If
FilePos = Element.fromFile(FilePos+Element.fileSize)
Wend
End Sub

Function Radix (num As double) As String
Const ch = " ABCDEFGHIJKLMNOPQRSTUVWXYZ$. 0123456789"
Dim temp As Double, _
ip1 As Long, _
ip2 As Long, _
ip3 As Long

If num = 0 Then
Radix = " "
Exit Function
Else
temp = num
End If
ip1 = temp \ 1600
ip3 = temp Mod 40
ip2 = ((temp - ip1 * 1600 - ip3) \ 40) + 1
ip1 = ip1 + 1
ip3 = ip3 + 1
Radix = Mid$(ch, ip1, 1) & Mid$(ch, ip2, 1) & Mid$(ch, ip3, 1)
End Function


HTH,
Simon

--
Remove NOSPAM from my address if replying.

Harry Stegeman

unread,
Dec 21, 2000, 7:03:34 PM12/21/00
to
Simon,

Thank you very much for the source.
The source looks very strange, but it works.

Can you explain me how it works?

Regards,

Harry Stegeman


"Simon Wurster" <swur...@NOSPAMworldnet.att.net> schreef in bericht
news:3A4294A0...@NOSPAMworldnet.att.net...

Simon Wurster

unread,
Dec 22, 2000, 6:27:17 PM12/22/00
to
Sorry Harry, but it's beyond me. If you open a design file in EdG that has saved
views, you search on type 5 level 9 elements and see the saved views there. I
suppose that you could extract other types of view information, such as range
(extent), level mask, view description, and even view attributes (Ctrl-B
options).
Still, the use of the line string vertex is a conundrum (line strings are type 4
elements and have more than 15 vertices), and I imagine the Radix() function
converts Radix50 notation (that is used to store the name of the view?) to ASCII
text.

Maybe it's just one of those "if it ain't broke, don't fix it" things.

Happy Holidays!
Simon

Harry Stegeman

unread,
Dec 23, 2000, 10:57:48 AM12/23/00
to
Simon,

It is a pitty that you can't explain how it works.

Isn't it possible to use the mdl function
mdlView_extractSavedView in MicroStationBasic,
like it has been done in the mdl routine svinfo.mc?

status = mdlView_extractSavedView ( name, description, &origin, &delta,
&activeZ, NULL, &rotMatrixP, levelsP,
&foundP, &extendedFlagsP,
&cameraInfoP, (short *) el);


Happy Holidays too.

Regards,

Harry Stegeman

ps. Bernhard Leicher do you know that it is possible.

Simon Wurster

unread,
Dec 24, 2000, 9:12:27 PM12/24/00
to
Hi Harry,
(Wow, it's 9pm Christmas Eve! Sorry Santa...)

I guess the problem with using MDL functions in MicroStation Basic is that it's
tough to determine the values required by the function in the context of Basic.
For example, how would one easily provide "&rotMatrixP" to the C expression,
since this data type doesn't exist in Basic? I've beat these to death at times,
sometimes with success, often without. We need better documentation for doing
this "black magic". Anyone at Bentley care to give us a nice Christmas present?

Harry Stegeman

unread,
Dec 27, 2000, 9:02:34 AM12/27/00
to
Simon,

If it is not possible to use the mdlView_extractSavedView function,
I want to use public variables to "translate" information from mdl
to MicroStationBasic.

I have a question:
- Is it possible to make an array of strings in mdl and use them
in microstationbasic?

In basic the variables would look like this.

'-----------------------
'VARIABLES
'-----------------------
Type SAVEDVStruct
name(64) as string
description(64) as String
End Type

Public SAVEDV as SAVEDVStruct

How can I translate these variables into mdl?

/*----------------------------------------------------------------------+
| |
| TypeDefs |
| |
+----------------------------------------------------------------------*/
typedef struct SAVEDVStruct
{
short name(64);
short description(64);
} SAVEDVStruct;

I thought that a short isn't an array of strings but integers, is
it possible make an array of strings in mdl?

Regards,

Harry Stegeman


"Simon Wurster" <swur...@NOSPAMworldnet.att.net> schreef in bericht

news:3A46AD09...@NOSPAMworldnet.att.net...

Dan MacNeil

unread,
Dec 27, 2000, 2:26:49 PM12/27/00
to
Harry,

The structure format in MDL you want is:

typedef struct savedvstruct
{
char name(7); // 6 characters max. for saved view name
char description(28); // 27 characters max. for description
} SAVEDVStruct;


You can use mdlBasic_setPublicVariable (...) to set the value of a
PREVIOUSLY defined Basic variable. The Basic program does not have
to be running at the time. The only problem here is you have to find
out how many saved views you have before you can declare the basic
variables.

You can search with a macro for saved views (type 5, level 3) to get a
count but be aware that Auxilliary Coordinate Systems are also stored
as (type 5, level 3). I believe they have slightly different formats
and sizes but I haven't looked at them much.

You could also make a separate Mdl function to count the number of saved
views in the file.

Hope this helps.

Dan

Harry Stegeman

unread,
Dec 27, 2000, 3:11:43 PM12/27/00
to
Dan,

Thanks for your response.

The structure format you did make in mdl
does not contain an array.

In the next structure I can save
64 savedview names and descriptions,
in your format I can only save 1 savedview
name and description.

> > name(64) as string
> > description(64) as String

Your structure in mdl would be same
as the next in basic.


'-----------------------
'VARIABLES
'-----------------------
Type SAVEDVStruct

name as string
description as String
End Type

Public SAVEDV as SAVEDVStruct


How can I make an text array in mdl?

Regards,

Harry Stegeman


"Dan MacNeil" <dan.42@home{dot}com> schreef in bericht
news:3a4a4172.4054032@news...

Dan MacNeil

unread,
Dec 27, 2000, 3:27:18 PM12/27/00
to
Harry,
First let me correct the definition (Note the Square Brackets!).

// Single saved view
typedef struct savedvstruct
{
char name[7]; // 6 characters max. for saved view name
char description[28]; // 27 characters max. for description
} SAVEDVStruct;

// Using arrays
typedef struct savedvstructarray
{
char name[64][7]; // 64 names of 6 charcaters
char description[64][28]; // 64 descriptions of 27 characters
} SAVEDVStructArray;

You could also declare an array of structures using the first structure:
SAVEDVStruct savedviews[64];

And access it with:
savedviews[12].name; //The eleventh saved view


Dan


On Wed, 27 Dec 2000 21:11:43 +0100, "Harry Stegeman"

jonsu...@my-deja.com

unread,
Dec 28, 2000, 9:55:09 AM12/28/00
to
Harry ...

> Does anybody know it is possible to extract or
> scan for the definitions of saved views in a
> design file?

Because this isn't so easy in MicroStation BASIC, I've written an
MDL helper application SV.MA

This helper will copy Saved View information to public variables in
your BASIC code. There's too much to post here, so I've submitted
it for publication in MicroStation Manager magazine.

If you would like the sample code and the helper, give me a call.

Regards, Jon Summers
LA Solutions


Sent via Deja.com
http://www.deja.com/

Harry Stegeman

unread,
Dec 28, 2000, 12:48:53 PM12/28/00
to
Jon,

Thanks for your response.

I did allready find an answer for getting an
array of public variables from mdl to mbebasic.

In your code I am missing the array of public variables.

svinfo.mc

/*----------------------------------------------------------------------+
| |
| Global Variables |
| |
+----------------------------------------------------------------------*/
typedef struct savedv
{
char name[256][7]; // 256 names of 6 charcaters
char description[256][28]; // 256 descriptions of 27 characters
} SAVEDV;

Private int j;

sprintf(outStringname, "SAVEDV.name(%ld%s",j,")");
sprintf(outStringdescription, "SAVEDV.description(%ld%s",j,")");

status = mdlBasic_setPublicVariable (name, sizeof(name),
outStringname);
status = mdlBasic_setPublicVariable (description, sizeof(description),
outStringdescription);

savedv2.bas

'-----------------------
'VARIABLES
'-----------------------
Type SAVEDV
name(256) as string
description(256) as String
End Type

Public SAVEDV as SAVEDV

Sub Main ()

For i% = 0 to 256
SAVEDV.name(i) = ""
SAVEDV.description(i) = ""
next

MbeSendCommand "mdl l svinfo"

End Sub

To get all the savedview name and description in
the public variables, I only have to excecute
the macro savedv2.bas.

Regards,

Harry Stegeman


<jonsu...@my-deja.com> schreef in bericht
news:92fk89$bpl$1...@nnrp1.deja.com...

awo...@googlemail.com

unread,
Jan 8, 2018, 8:22:18 PM1/8/18
to
0 new messages