• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Editing the modeldef in ModelDef Viewer

Heretic

Resource contributor
Messages
6,830
Country
germany
Dumb question: Can the Modeldef in the ModelDef Viewer be edited?

If not: How hard would implementing such a capability be?


This would be immensely useful for efficiently eliminating buggy code in animation, visibility or mouserect tags.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
Hi,

I'm actually using an editor control, so allowing editing is quite easy. It's now disabled to prevent users from messing things up. But if it's useful, I can allow editing.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
That'd be great!

Maybe an "Unlock for editing" button or so.
And an "undo/redo" feature, if possible.
And only allowing model export with a locked ModelDef Viewer.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
I'll have a look into it. It's a good idea to have an unlock edit button.

Saving is not restricted by any editor state, so that won't be implemented. But I also don't think it's needed, if somebody messes up it's their own responsibly :)
 

Heretic

Resource contributor
Messages
6,830
Country
germany
It would have been a bit of an insurance against accidential typos or unwanted data entry, but fair enough.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
One additional constraint by the way, if you would change the name of definitions in the modeldef.xml, that would not affect the nodes in the model that use these definitions.
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
For safety's sake, save a copy of the original once someone enters the Edit state.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
That's a good question actually, where should the changes go? Stay in memory until you save the model or should they be saved to your disk?

Remember that in MCX the modeldef.xml can be different from disk already, because when loading a MDL file custom definitions can be added that are not in the version on your disk.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
Hi,

I have made a first implementation now, I'll push a new development release right away.

In edit mode the changes are stored in memory first. They are only written to disk if you manually use the save button to do so. Let me know if this works and if other changes are needed.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
Entering edit mode makes MCX throw an unhandled exception.
All I did was search for a string and then click the "Edit Mode" button.

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.LoadXml(String xml)
at ASToFra.FSUtils.ModelDef..ctor(String content)
at ASToFra.ModelConverterX.ModelDefEditor.XmlEditorDocumentChanged(Object sender, DocumentEventArgs e)
at DigitalRune.Windows.TextEditor.TextEditorControl.OnDocumentChanged(DocumentEventArgs documentEventArgs)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at DigitalRune.Windows.TextEditor.Document.DefaultDocument.OnDocumentChanged(DocumentEventArgs e)
at DigitalRune.Windows.TextEditor.Document.DefaultDocument.set_TextContent(String value)
at DigitalRune.Windows.TextEditor.TextEditorControl.LoadFile(String fileName, Stream stream, Boolean autoLoadHighlighting, Boolean autodetectEncoding)
at DigitalRune.Windows.TextEditor.TextEditorControl.LoadFile(String fileName, Boolean autoLoadHighlighting, Boolean autodetectEncoding)
at ASToFra.ModelConverterX.ModelDefEditor.LoadModelDef()
at ASToFra.ModelConverterX.ModelDefEditor.CmdEditModeClick(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2633.0 built by: NET471REL1LAST_C
CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
ModelConverterX
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ModelConverterX.exe
----------------------------------------
ASToFra.ErrorHandler
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.ErrorHandler.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
ASToFra.Utils
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.Utils.DLL
----------------------------------------
ASToFra.Interfaces
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.Interfaces.DLL
----------------------------------------
ASToFra.ObjectModel3D
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.ObjectModel3D.DLL
----------------------------------------
ASToFra.ObjectReader
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.ObjectReader.DLL
----------------------------------------
ASToFra.ObjectWriter
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.ObjectWriter.DLL
----------------------------------------
ASToFra.EventLog
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.EventLog.DLL
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2556.0 built by: NET471REL1
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2633.0 built by: NET471REL1LAST_C
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.7.2612.0 built by: NET471REL1LAST_B
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
ASToFra.ObjectRenderer
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.ObjectRenderer.DLL
----------------------------------------
CSGL12DLL
Assembly Version: 12.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/CSGL12DLL.DLL
----------------------------------------
ASToFra.ParticleEffects
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.ParticleEffects.DLL
----------------------------------------
ASToFra.FSUtils
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.FSUtils.DLL
----------------------------------------
ASToFra.TextureObject
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.TextureObject.DLL
----------------------------------------
lib3ds.Net
Assembly Version: 2.0.0.37657
Win32 Version: 2.0.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/lib3ds.Net.DLL
----------------------------------------
ASToFra.TextureLoader
Assembly Version: 1.0.0.0
Win32 Version: 1.4.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/ASToFra.TextureLoader.DLL
----------------------------------------
DigitalRune.Windows.TextEditor
Assembly Version: 1.3.0.0
Win32 Version: 1.3.0.0
CodeBase: file:///F:/Development%20Utilities/Model%20Converter%20X/DigitalRune.Windows.TextEditor.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
That's a good question actually, where should the changes go? Stay in memory until you save the model or should they be saved to your disk?

What about a subfolder in MCX' folder; named after the model file?
Unless the generated Modeldef is saved manually someplace else, MCX may delete it after the session ends.

Oh, and the "Only show used" setting should determine just how much of that Modeldef is saved.

Remember that in MCX the modeldef.xml can be different from disk already, because when loading a MDL file custom definitions can be added that are not in the version on your disk.

Ideally, you could also switch between both Modeldefs as a source in the Hierarchy and Animation Editors, but that'd necessitate some UI changes.

(And I think we've discussed this before, but the Modeldef defined in MCX' export options is only loaded once at program start, isn't it?)


One additional constraint by the way, if you would change the name of definitions in the modeldef.xml, that would not affect the nodes in the model that use these definitions.

That's understood.

What would happen if I, say, modified a part's custom ModelDef code in the Viewer, then closed the Viewer, deleted everything but that part in the Hierarchy Editor and opened the Modeldef Viewer again? Would I still see the custom code for the other parts? Would my changes be retained?
 
Last edited:

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
Hi Bjorn,

When did you press the button? After loading a model?

What about a subfolder in MCX' folder; named after the model file?
Unless the generated Modeldef is saved manually someplace else, MCX may delete it after the session ends.

I feel it becomes too confusing if many ModelDef.xml files are saved in different locations. So I prefer to keep things as simple as possible. That's why I added a Save button now to let the user save it wherever he wants.

Oh, and the "Only show used" setting should determine just how much of that Modeldef is saved.

I have disabled the Only show used option now, because starting to edit with this option on will result in loosing all other content of the ModelDef.xml file. Sometimes that might be wanted, but most of the time not I guess.

Ideally, you could also switch between both Modeldefs as a source in the Hierarchy and Animation Editors, but that'd necessitate some UI changes.

(And I think we've discussed this before, but the Modeldef defined in MCX' export options is only loaded once at program start, isn't it?)

I doesn't really make sense to switch the ModelDef.xml on file if MCX has added extra content from the model loaded I would say. Why would you want to do that?

The ModelDef.xml file is read from disk everything time a new model is loaded, because the custom entries are then cleared.

What would happen if I, say, modified a part's custom ModelDef code in the Viewer, then closed the Viewer, deleted everything but that part in the Hierarchy Editor and opened the Modeldef Viewer again? Would I still see the custom code for the other parts? Would my changes be retained?

Changes should be retained in that case. Deleting parts would not edit the ModelDef.xml, so all entries are still there.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
When did you press the button? After loading a model?

Yep. Loaded a FSX format model, opened ModelDef Viewer, pressed "edit" button. But see below as to why MCX crashed.

I feel it becomes too confusing if many ModelDef.xml files are saved in different locations. So I prefer to keep things as simple as possible. That's why I added a Save button now to let the user save it wherever he wants.

Fair enough.

I have disabled the Only show used option now, because starting to edit with this option on will result in loosing all other content of the ModelDef.xml file. Sometimes that might be wanted, but most of the time not I guess.

Just found out that the "Only show used" function is what crashes MCX if it's activated while entering edit mode.
Disabling "only show used", then editing the ModelDef and, after disbling edit mode reenabling "only show used" works just fine and retains any changes made.

So I figure all that's needed is getting the status of "only show used" when entering edit mode, disablign it if necessary, and resetting that status when leaving edit mode.

Considering Modeldef files with 30000+ lines, "only show used" is immensely useful.

I doesn't really make sense to switch the ModelDef.xml on file if MCX has added extra content from the model loaded I would say. Why would you want to do that?

A day later, I'm not sure anymore. Maybe it had something to do with the sheer mass of tags that are contained in a ModelDef file that's generated when combining the already huge disk-based ModelDef with the serveral hundred new tags in a complex model.
Thanks to the name-based search in the Animation Editor, this poses not much of a problem, but the selection lists in the Hierarchy Editors become a bit of a mousewheel hell. Hence the ability to at least discriminate between tags from the disk-based modeldef and custom tags contained in the model.

Speaking of: Is a ModelDef tag added in the ModelDef Viewer be available in the Hierarchy and Animation Editors?


Changes should be retained in that case. Deleting parts would not edit the ModelDef.xml, so all entries are still there.

Affirmative; I've just tested this.

Edited a part's custom animation tag in "Edit" mode and deleted everything but that part in the hierarchy editor.
The ModelDef Viewer retains my edits to the code as well as all tags that it initially extracted from the model.
"Only show used" even works, only showing the animation code for the remaining part. Pretty cool.
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
Yep. Loaded a FSX format model, opened ModelDef Viewer, pressed "edit" button. But see below as to why MCX crashed.

Just found out that the "Only show used" function is what crashes MCX if it's activated while entering edit mode.
Disabling "only show used", then editing the ModelDef and, after disbling edit mode reenabling "only show used" works just fine and retains any changes made.

So I figure all that's needed is getting the status of "only show used" when entering edit mode, disablign it if necessary, and resetting that status when leaving edit mode.

OK, I'm sure I did that during testing yesterday as well, but I'll check again. I thought I already disable the Only show used when entering edit, but there must be a situation where that doesn't work :).

Considering Modeldef files with 30000+ lines, "only show used" is immensely useful.

I could also allow editing with the Show only used on. But in that case it is the responsibility of the user that he might loose the not used definitions. Not sure if that is confusing or not.

Speaking of: Is a ModelDef tag added in the ModelDef Viewer be available in the Hierarchy and Animation Editors?

Yes, they should be available immediately (you might need to re-select the node to refresh the list of possible values).
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
Hi,

I have fixed the crash now.

I have also changes the code so that you can edit when "Show only used" is on. Just be aware that doing so can loose the things you don't see.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
I could also allow editing with the Show only used on. But in that case it is the responsibility of the user that he might loose the not used definitions. Not sure if that is confusing or not.

Shouldn't be, but I'd have to test it before I can make a judgement.
 

Heretic

Resource contributor
Messages
6,830
Country
germany
Tested it. Doing any editing whatsoever in "only show used" mode deletes all unused ModelDef tags when returning to "show all" mode.
This is actually a nifty way to quickly clean up the list of avialable tags in for the Animation and Hierarchy Editors, but on the other hand, it really is undesirable in other scenarios.

Maybe show a warning popup when entering edit mode in "only show used" mode?
Or implement the automatic toggling of "only show used" when entering edit mode with an option to override it in the preferences menu?


By the way:
When in edit mode, typing "<" anywhere crashes MCX.



- Edit:

The "Save Modeldef" function takes the status of the "only show used" tickbox into account. Cool!
 
Last edited:
Messages
11
Country
russia
I apologize. Probably I do not understand something, but how can I edit the ModelDef?
I need to make minor corrections of syntax errors (extra "{{" in the code, etc.). I open the "ModelDef show", I remove the "Show only used" checkbox, click "Edit mode" and then I find and correct the necessary fragment. But after exporting and reloading the model, everything remains as before.
Maybe I'm doing wrong? MCX last v 1.4.0.0 3... from 13.06.18.
I am grateful for any help.

Edward
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
Messages
32,883
Country
netherlands
Hi,

Are you sure the animation that was changed is used in the model? And did you save the changes to disk?
 
Messages
11
Country
russia
This is not an animation, it's a visibility condition. It is used in the model, the error of this code is given by ContentErrorLogging.
And how to save changes to disk? Probably just this I do not understand.
PS
Oops ... Sorry, this is really an animation. Here is the error code in Prepar3D:
Code:
error=Gauge/Script Error
Type: Animation Script
Name: Swiss Bombardier CS300
Error: Invalid script (command not found - perhaps a space is missing or there's an extra space?): "{" in: { 150 } els{ (A:ROTATION VELOCITY BODY Y, Feet) 20 * 150 + } }
 
Last edited:
Top