Cancel
Showing results for 
Search instead for 
Did you mean: 

Plant Sim 14 - Saving the Model Through Code

Gears Phenom Gears Phenom
Gears Phenom

Hello all.

 

A couple of my tools save the model before they run because they do processes that could cause issues to occure, since upgrading to version 14.0 I have noticed that the model is not being saved by these tools, using the Expression section of the debug window I can show what is the issue.

 

Plant Sim V14-0 SaveModel.PNG

 

As you can see, here is 3 different methods of saving the model, all of my tools use the middle method where needed to not save the current state of any running methods. The top one has been added to expose the return value but is effectivly the same.

 

You can see, when ExecuteSilent is used to save the model false is returned as the model is not saved, while if you call SaveModel normally then the model is saved and true is returned as you would expect.

 

Should we still be using 'ExecuteSilent("SaveModel(modelFile)")' to save the model without any currently running methods or is there another approach that we should be doing?

 

JamesM

9 REPLIES

Re: Plant Sim 14 - Saving the Model Through Code

Siemens Phenom Siemens Phenom
Siemens Phenom

I guess you need to uncheck the check-box "File > Model Settings > General > Prohibit access to the computer" first. Note that saveModel could overwrite any file and is therefore potentionally harmful.

 

I would advise not to enter saveModel as an expression in the Method Debugger. The expressions are evaluted (i.e. executed) each time the Debugger window is being opened or updated!

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: Plant Sim 14 - Saving the Model Through Code

Gears Phenom Gears Phenom
Gears Phenom

Hello,

 

I have already changed that setting as it is needed for other features of the tools (the main tool in question exports a lot of different files, so runs a combination of saving tables, creating txt files and running command line code).

 

I know, only entered them to show the effect and then removed them straight away, could not think of a more clear way to show the results.

 

JamesM

Re: Plant Sim 14 - Saving the Model Through Code

Gears Phenom Gears Phenom
Gears Phenom

Hello,

 

At the same time I can confirm that the following lines of code have also stopped working, being called in a similar fashion (this time due to the fact they could fail):

 

ExecuteSilent("param o: Object, s: String; o._3D.ExportAsS3D(s);", target, To_Str(saveLocation, "\Model.s3d"))
ExecuteSilent("param o: Object, s: String; o._3D.ExportAsJt(s);", target, To_Str(saveLocation, "\Model.jt"))

These will not save the 3D graphics of the object at all, this could be updated to use a error handler instead to have the same feature, using it to point Plant Sim back to this point within the code, but I wish to advoid doing this at all cases if it can be helped.

 

I fear that it is due to the ExecuteSilent work space not having access to the computer while the model itself does.

 

JamesM

Re: Plant Sim 14 - Saving the Model Through Code

Siemens Legend Siemens Legend
Siemens Legend

Dear James,

 

First - do you have model you can share here to test it?

 

Second - the new security settings have two states:

  1. the model (File/Model settings/General Tab/Prohibit access to the computer)

    2017-10-18_13-49-09_Greenshot.png

     

  2. the library (Class Library/Context Menu/Edit Library Info/Prohibit access to the computer)2017-10-18_14-13-10_Library Information.png

      

If a method is executed containinga security relevant, computer accessing function/method, then it is tested if …

  1. … the model setting prohibits access
  2. … the method is originated in a library, which prohibits access

I made a sample 3D model containg two methods to …

  1. export as S3D file and
  2. using ExecuteSilent to try the S3D export.

… instanciated from a library with prohibited access and instantiated from the class library.

 

The sample 3D model has access permitted in its model setetings, so all methods could succeed in exporting, creating files with 3D data.

But since the library has prohibted access, the methods (without ExecuteSilent) instantiated from this library raises the debugger with the related access error.


2017-10-18_13-52-44_.Models.Frame.Method2.png

 

 

The method with ExecuteSilent instantiated from the library with prohibited access will fail silently!

 

Using ExecuteSilent does not cause the debugger to popup, so an error while accessing the computer is not reported nor easily recognizable.

 

I attached the sample model to this reply.

 

If you can provide a sample model, I'll take a look.

 

Best regards,

 

Martin Lemburg

Martin Lemburg


Siemens PLM Software
Digital Factory Division
Product Lifecycle Management
Manufacturing Engineering Software / R&D / Plant Simulation
Siemens Industry Software GmbH, Berlin / Germany

Did you like the answer? Then click the Thumbs Up button.

Did the answer solve your problem? Then accept the answer as solution

Re: Plant Sim 14 - Saving the Model Through Code

Gears Phenom Gears Phenom
Gears Phenom

Hello Martin,

 

I have created a model (see attached) which can demostrate the issue, in reality what I am doing is part of a much larger process and I do not wish to post that online due to the amount of time invested in it.

 

 

This model is simple, there is an entire frame to be exported, all graphics within that frame (and all sub frames) will be exported apart from connectors.

 

You can find a frame at .Toolkit which includes a button and a variable, change the variable to point to the place you wish to save the export and then click the button and it will start to export each graphic in the frame, creating new folders as needed to do so.

 

Within this model, when I run the button using Execute Silent (as the model is configured to do so now) then all of the folders are created (using startExtProc function to perform a command line command which I am sure requieres full computer access) but no graphics are created within them.

 

If instead I am to comment out the Execute Silent lines and uncomment the other lines then it is exported correctly.

 

 

This should be the exact same behaviour as when trying to use Execute Silent to save the model as well. Hopefully the model performs the same function your end as it does mine.

 

JamesM

Re: Plant Sim 14 - Saving the Model Through Code

Siemens Legend Siemens Legend
Siemens Legend

Hello James,

 

Thanks for the test model!

 

I was able to reduce the complexity of the model to some essentials to reproduce the problem.

I'll get back to you after talking to a colleague about the reasons and the current available work-arounds!

 

Best regards

Martin Lemburg


Siemens PLM Software
Digital Factory Division
Product Lifecycle Management
Manufacturing Engineering Software / R&D / Plant Simulation
Siemens Industry Software GmbH, Berlin / Germany

Did you like the answer? Then click the Thumbs Up button.

Did the answer solve your problem? Then accept the answer as solution

Re: Plant Sim 14 - Saving the Model Through Code

Siemens Legend Siemens Legend
Siemens Legend

Dear James,

We identified a problem and are working onto fixing it.

In the meanwhile I would suggest to separate the user-defined methods from their object, to create "standalone" methods with the same functionality than those "attached" to the object as user-defined-attribute.

"ExecuteSilent" in normal methods works like expected, so this would allow you to continue and to step back to methods as user-defined attributes, when we fixed the problem.

Best regards

Martin Lemburg


Siemens PLM Software
Digital Factory Division
Product Lifecycle Management
Manufacturing Engineering Software / R&D / Plant Simulation
Siemens Industry Software GmbH, Berlin / Germany

Did you like the answer? Then click the Thumbs Up button.

Did the answer solve your problem? Then accept the answer as solution

Re: Plant Sim 14 - Saving the Model Through Code

Gears Phenom Gears Phenom
Gears Phenom

Hello,

 

Will try doing that soon and checking if it works correctly or not then, but for me I use user defined attributes all the time to ensure that the model stays tidy so am a bit reluctent to do so for now if the fix will arrive before I need to next use the tools.

 

JamesM

Re: Plant Sim 14 - Saving the Model Through Code

Siemens Legend Siemens Legend
Siemens Legend

Good morning James from Berlin,

 

I fully understand your arguments and yes, you are right to structure your models this way!

But sincerely the described work-around is the current way to get your things working!

 

The good news is, that we have fixed the reason for your reported problem and that the next maintenance pack will bring this fix to you.

So 14.0.2 will fix the problem with "ExecuteSilent" in methds, that are user defined attributes!

 

Best regards and a happy weekend

Martin Lemburg


Siemens PLM Software
Digital Factory Division
Product Lifecycle Management
Manufacturing Engineering Software / R&D / Plant Simulation
Siemens Industry Software GmbH, Berlin / Germany

Did you like the answer? Then click the Thumbs Up button.

Did the answer solve your problem? Then accept the answer as solution