I entered the NASAL code as described, this code is followed correctly, but does not go ahead because it reports an error for the reference of an object in the SVG file that I want to bind to a surface:
This is the NASAL code execute in G91-set.xml file:
- Code: Select all
<nasal>
<G91>
...
<file>Aircraft/G91/Models/Parts/Cockpit/Gauges/Nasal/canvas_instrument.nas</file>
<file>Aircraft/G91/Models/Parts/Cockpit/Gauges/PHI/CanvasPHIWind01.nas</file>
...
</G91>
</nasal>
This is the NASAL code insert in the folder that contain the SVG file and .ac file:
- Code: Select all
var CanvasPHIWind01=
{
new : func
{
var obj = CanvasInstrument.new("Aircraft/G91/Models/Parts/Cockpit/Gauges/PHI/PHIWind01.svg", "PHIWind01M", 0,0);
obj.face = obj.get_element("face");
obj.face.setCenter(512,512);
obj.canvas.setColorBackground(0.36, 1, 0.3, 0.00);
obj.update_items = [
PropertyUpdateManager.new("instrumentation/altimeter/indicated-altitude-ft", 1.0, func(alt_feet)
{
obj.face.setRotation(alt_feet*0.36*0.01744591);
})
];
},
};
aircraft.alt = CanvasPHIWind01.new();
The name of SVG file in my test is:
"PHIWind01.svg"
I'm sure the SVG file is read correctly because if I rename the NASAL program I get an error if I did not find the file.
If I open the SVG file with an editor I look he layer name "face", so it seems all right:
- Code: Select all
</metadata>
<g
inkscape:label="face"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-28.362161)"
style="display:inline">
<g
But when the NASL code is execute (The NASAL code is Execute in the ..-set file as explained in the instructions.
Along with this NASAL file there is a second file that is run earlier and contains the standard methods for creating elements with NASAL elements.
This file also runs and reports a debug message that is shown below:
- Code: Select all
PHIWind01M: Parse SVG 1 for surface CanvasPHIWind01MFace
But immediately after uploading the SVG object to display I find this message:
- Code: Select all
Failed to locate face in SVG
Nasal runtime error: non-objects have no members
at /home/abassign/Documenti/fgfs/G91/Models/Parts/Cockpit/Gauges/PHI/CanvasPHIWind01.nas, line 12
called from: /home/abassign/Documenti/fgfs/G91/Models/Parts/Cockpit/Gauges/PHI/CanvasPHIWind01.nas, line 22
Which message says he did not find in the SVG the required layer!
At this point, I could no longer go on as the message seems to be such that I do not give another operating method.
My suspicion is that I'm using a wrong methodology, but I do not understand what it can be. Besides, there is a second problem: but how do I define the object in the .ac file that I want to cover with the image?
Thanks for your help