PDA

View Full Version : Save as drawingnumber.mi with macro


jkramer
06-05-2006, 10:45 PM
Hi,

I hope someone can help me out: I have no macro-experience in ME10, because we use Annotation, but our pre-production collegues use Web Access and ME10 to fetch our drawings.
The line
STORE MI ALL DEL_OLD ‘c:\local/radan.mi’
was added to the load macro, so that an MI-file is exported from ME10 once the frame and the drawing are loaded. The pre-production guys can now import the file in Radan with "import MI".
So far so good. BUT, now they would like <drawingnumber>.mi instead of the name radan.mi.
Can anyone tell me how I can do this?? I suppose it should be possible to query the database attribute "NAME" of this drawing??? In other words, I want to read the value of the text with text reference "NAME".

Thanks!
Regards,
Jaap

Peter Boks
06-06-2006, 05:02 AM
The INQ_ENV command sets values about the ME10 system.
Ater this command you can obtain these values using the related INQ code.

In your case you could use these commands as follows:

INQ_ENV 0 {sets several values including the full path and filename of the active file}
LET Filenaam (INQ 304) {create a variable with the full path and filename}
LET Filenaam (Filenaam+".mi") {add .mi to the filename}
STORE MI ALL DEL_OLD Filenaam {store the file as filename.mi}

There is a lot of information about this in the helpfiles.
So if you want to learn more, the ME10 helpfiles are a good place to start.

Best regards,
Peter Boks

jkramer
06-06-2006, 05:08 AM
Hi Peter,

Thanks a lot! This is what I needed!

Regards,
Jaap

jkramer
06-06-2006, 06:06 AM
...however....
The problem is that INQ 304 gives me the same name all the time (because that's the way Web Access temporarily saves it).
When I type LIST_GLOBAL_INFO, i get all infotexts. One of them is SD_N, which gives me the drawing name I want.
Is there any way to inquire SD_N, so that I can use it?? I've searched the manual for the past hour, and I don't see a trick....

Thanks!
regards,
Jaap

John Scheffel
06-06-2006, 11:57 AM
Something like this might work. It inquires all text elements with the INFO 'SD_N' attached, then sets a variable to the first line of text for the first element found with that info attached. If the Drawing Number field is the only text with that INFO attached it should work.

DEFINE Get_drawing_number
INQ_SELECTED_ELEM SELECT GLOBAL TEXTS INFOS 'SD_N' CONFIRM
IF ((INQ 14)<>0)
LET Drawing_number (INQ 902)
ELSE
LET Drawing_number 'None'
END_IF
END_DEFINE

Marten
06-06-2006, 12:08 PM
Hi Jaap,

If you want to read a value from a text field:

inq_selected_elem select infos "TR:Sheet_global:DRAWING_NO:2:0:1:-102:1:0" confirm {select the text field}
let filename ((inq 902) + ".mi") {inquire its text value}

You will have to find out the exact info-string which is attached to the text-field. If this info string


Or, if you want to read the value from an info-string of the top part, you could use code like this:

edit_part top
inq_selected_elem select (inq 301) confirm end {inquire top part}
let lvInfoString (inq 900)
while (lvInfoString <> 'END-OF-LIST') {loop through all info-strings to find the one you need}
if ((pos lvInfoString 'SD_N:')>0)
let filename ((substr lvInfoString ((pos lvInfoString ':')+2) + ".mi")
end_if
let lvInfoString (inq 901)
end_while

I haven't tested the code, so it will probably contain errors, but you should be able to do it in either way.


I hope this helps you a bit.

Regards,

Marten Verhoeven

jkramer
06-07-2006, 01:29 AM
Hi,

thanks for both reactions!
I ended up using this code:
edit_part top
INQ_SELECTED_ELEM SELECT GLOBAL TEXTS INFOS "TR:tb:NAME:2:0:1:-102:1:0" CONFIRM
LET Filenaam (INQ 902)
LET Filenaam ("C:/local/"+Filenaam+".mi")
STORE MI ALL DEL_OLD Filenaam

If I searched for 'SD_N', it would only work if the frame would be the current part, and I don't know how to automatically select the frame....
Another weird thing is that if I used John's If-statements, the macro didn't work at all. This surprises me, because if I type in the INQ_SELECTED_ELEM command, and after that DISPLAY (INQ 14), I get value 1; after that I type DISPLAY (INQ 902) and I get my desired number. ????!!!!!
Anyway, it works now!
Thanks again,
Regards,
Jaap

John Scheffel
06-07-2006, 09:12 AM
Hi Marten,

Thanks for providing the detailed answer. Two tips on posting code. If you enclose in code tags it will preserve indentation and formatting. For example.


My code


You can add the code tags from the # button in the edit form or just type them.

Also, you might want to check "Disable smilies in text" especially when posting LISP code since LISP often contains colon character sequences which vBulletin converts to smilies by default. You can also make these changes after posting by editing your posts and clicking "Go Advanced".