Cancel
Showing results for 
Search instead for 
Did you mean: 

How to call create CSys Standard Windows through API?

Valued Contributor
Valued Contributor

Hello, everybody!

 

I wrote a routine that in certain point ask user to choose a reference coordnate system (CSys). For this, I've created a dialog box with a combobox where the user is able to choose one of the existing CSys. I would like to include in this dialog box a button that would allow the user to create a new CSys, as he wishes. I thought to call through this button the standard window "Define Coordinate System" (the same as to click at Model/Coord Sys...), thus, the user would create his new CSys and the routine would go on running normally. The problem is that I researched the FEMAP's API manual, and couldn't find a command to call this standard dialog box. Isn't it possible to do this?

 

Best regards,

 

Fabiano.

4 REPLIES

Re: How to call create CSys Standard Windows through API?

Siemens Phenom Siemens Phenom
Siemens Phenom

Anytime you want to use a FEMAP command from the UI that isn't directly exposed in the API, you can always resort to calling a program file from the API. To have the user create a Coordinate System, you could simply include

 

App.feFileProgramRun ( False, True, False, "{MY}" )

 

This will display the dialog boxes so you can create a coordinate system. The only problem with this is that the coordinate system command repeats... so you would have to cancel the dialog boxes to return to the API. This could be a good thing if you wanted to be able to create multiple coordinate systems, but if you wanted to limit to 1 it is a problem.  Luckily the repeat behavior can be disabled by including

 

App.Pref_RepeateCreate = False

 

prior to calling feFileProgramRun.  You probably also should set it back to True afterward to maintain the normal UI behavior.

Re: How to call create CSys Standard Windows through API?

Valued Contributor
Valued Contributor

Thank you, grudy!

 

It was exactly what I needed!

 

Fabiano.

Re: How to call create CSys Standard Windows through API?

Legend
Legend

Hi Fabiano,

 

there is an another command to solve your problem. You can use feRunCommand too. In your case:

 

App.feRunCommand (1151, True)

Here is a small code to find the ID of the command to run:

 

Sub Main
    Dim App As femap.model
    Dim sMenuName As String
    Dim sSubmenuName As String
    Dim numCmds As Long
    Dim cmdID As Variant
    Dim cmdTitle As Variant
    Dim msg As String
    Set App = feFemap()
    sMenuName="Model"
    sSubmenuName="Load"
    rc=App.feGetMenuCommands(sMenuName,sSubmenuName, numCmds, cmdID, cmdTitle)
    msg=""
    App.feAppMessage( FCM_COMMAND  , "List MenuCommands to Messages")
    For i=1 To numCmds
        msg=CStr(cmdID(i-1))+" "+cmdTitle(i-1)
        App.feAppMessage( FCM_COMMAND , msg)
    Next
End Sub

In your case, when you want to know the ID of the command Model -> Coord Sys..., you should write in code sSubmenuName="" instead of sSubmenuName="Load".

 

The difference between commands feRunCommand and feFileProgramRun:

 

When you use feFileProgramRun, your API doesn't wait to execution of the program file (in your case to creating coordinate system). When you use feRunCommand, your API wait to finishing this command.

 

Best regards

 

Peter Kaderasz

 

Re: How to call create CSys Standard Windows through API?

Valued Contributor
Valued Contributor

Hi Peter!

 

I was using the command feFileProgramRun and to force the API to wait the execution of the program file, I was using the command feFileProgramRunning. After calling the feFileProgramRun, i wrote a loop that checks if a file program is currently running. The API goes out of this loop only when the program file is finished.

Sub Main
    Dim App As femap.model
    Set App = feFemap()

    App.Pref_RepeateCreate = False
	App.feFileProgramRun(False, False, False, "`{MY}")
	rc = App.feFileProgramRunning
	While rc = FE_OK
		rc = App.feFileProgramRunning
	Wend
	App.Pref_RepeateCreate = True
End Sub

 

I think the use of command feRunCommand is quite simple and I will revise my code to implement your suggestion.

 

Thank you!

 

Fabiano