Automatically add or remove the Line "ZL"

Note that alterations to the YSFlight .EXE is forbidden
Post Reply
User avatar
Vistara 001
Newbie
Newbie
Posts: 7
Joined: Sat Sep 19, 2020 7:17 am
Favorite Aircraft: Boeing 747
Location: Area 69, India
OS: Pop! OS, Arch
Has thanked: 1 time
Been thanked: 5 times
Contact:

Automatically add or remove the Line "ZL"

Post by Vistara 001 »

It adds the line "ZL" or removes the line "ZL". It works with YSF planes .dnm files.
How to use

Step 1 > Create a input and a output folder in same directory (Terminal mkdir input && mkdir output).
Step 2 > Put the Required files in the input folder.
Step 3 > Now open terminal in same folder and run python main.py and it will process the file.
Note :- It removes "ZL" from files and adds "ZL" to lines with five spaces.
Step 4 > Required files are in the output folder.

Visit GitHub page to download.
User avatar
u2fly
Senior Veteran
Senior Veteran
Posts: 1485
Joined: Fri Oct 02, 2015 9:27 am
Favorite Aircraft: Antonov An-225 Mriya
Location: Ukraine
OS: Linux
Has thanked: 1051 times
Been thanked: 339 times

Re: Automatically add or remove the Line "ZL"

Post by u2fly »

Vistara 001 wrote: Mon Mar 15, 2021 3:07 pm It adds the line "ZL" or removes the line "ZL". It works with YSF planes .dnm files.
Nice! But could you add more details on this script? For what purpose it may be useful?

U.S. Senator John McCain wrote:“Spending #NewYearsEve w/ brave #Ukrainian Marines at a forward combat outpost
- we stand w/ them in their fight against #Putin's aggression”

pic.twitter.com/vkz0gdozVV [archived]
(31 DEC 2016)
User avatar
Flake
VFA-49
VFA-49
Posts: 4375
Joined: Thu Feb 10, 2011 8:47 pm
Favorite Aircraft: Boeing F/A-18A
Location: Australia
OS: Windows 10 (x64)
Has thanked: 861 times
Been thanked: 1279 times
Contact:

Re: Automatically add or remove the Line "ZL"

Post by Flake »

Also curious.

By the way, very small source code footprint at 22 lines. I had a read and seems to do exactly what is says on the label.

It'll work on any filetype, so DNM and SRF will go fine.

Essentially, if the line contains "ZL", the "ZL" is replaced with nothing ("").
Is the line contains 5 spaces "     ", then that is replaced with "ZL" is instead.

I'm not sure what this achieves personally. IIRC ZL adds a "light" to the polygon referenced, like the lights on the stock F22. Is that right?

So this script will add lights to polygons, or remove them?

So far, despite being new to the forums, a good (and safe to run!) contribution.

----

On a code standpoint, some feedback?

Line 1: No need to print, this can be a comment.
Line 4: Rename the variable "old" to something more descriptive, eg: fileInInputFolder
Line 6: "f" could be "file", not sure of the variable limits in Py. personal preference though, as "f" gets the job done.
Lines 10/11: Swap these. Say you'll do something, THEN do it, not the other way around.
Lines 14/15: Ditto.
Line 17: Consider wrapping your entire file open/close in a try/catch/finally to safely close the file reference.
Line 19: You're ignoring file extension and assuming .dnm here.
Line 19: Reusing the variable "f" for a different file is not a good idea. I advise "inputFile" and "outputFile" as your variables.
I am an accountant working full-time (and some). I'm not here as often as I would like to be. Send a message if you need me. There are a few people in the community who can get in contact with me urgently if you need - don't be afraid to ask. I just don't check here as frequently as I used to. Sorry!
User avatar
Vistara 001
Newbie
Newbie
Posts: 7
Joined: Sat Sep 19, 2020 7:17 am
Favorite Aircraft: Boeing 747
Location: Area 69, India
OS: Pop! OS, Arch
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: Automatically add or remove the Line "ZL"

Post by Vistara 001 »

u2fly wrote: Mon Mar 15, 2021 5:41 pm For what purpose it may be useful?
Actually I am not sure. I just created it help one my friend.
ZL is a line in the DNM files that makes lights shine.
DNM is for dynamic model. SRF is for surf. These can be opened using notepad.
But normally they're used in 3D editing programs like blender.
So the idea is to make a python tool than can open DNM files and have ZL deleted or replaced by space.
It would work by putting DNM into an input folder and once they're processed, they'll show up in an output folder.
User avatar
Vistara 001
Newbie
Newbie
Posts: 7
Joined: Sat Sep 19, 2020 7:17 am
Favorite Aircraft: Boeing 747
Location: Area 69, India
OS: Pop! OS, Arch
Has thanked: 1 time
Been thanked: 5 times
Contact:

Re: Automatically add or remove the Line "ZL"

Post by Vistara 001 »

The code is quite messed up as I wrote it in hurry as my one of my friend needed it urgently. :lol:

----
Flake wrote: Tue Mar 16, 2021 11:54 am Also curious.

By the way, very small source code footprint at 22 lines. I had a read and seems to do exactly what is says on the label.

It'll work on any filetype, so DNM and SRF will go fine.

Essentially, if the line contains "ZL", the "ZL" is replaced with nothing ("").
Is the line contains 5 spaces " ", then that is replaced with "ZL" is instead.

I'm not sure what this achieves personally. IIRC ZL adds a "light" to the polygon referenced, like the lights on the stock F22. Is that right?

So this script will add lights to polygons, or remove them?

So far, despite being new to the forums, a good (and safe to run!) contribution.

----

On a code standpoint, some feedback?

Line 1: No need to print, this can be a comment.
Line 4: Rename the variable "old" to something more descriptive, eg: fileInInputFolder
Line 6: "f" could be "file", not sure of the variable limits in Py. personal preference though, as "f" gets the job done.
Lines 10/11: Swap these. Say you'll do something, THEN do it, not the other way around.
Lines 14/15: Ditto.
Line 17: Consider wrapping your entire file open/close in a try/catch/finally to safely close the file reference.
Line 19: You're ignoring file extension and assuming .dnm here.
Line 19: Reusing the variable "f" for a different file is not a good idea. I advise "inputFile" and "outputFile" as your variables.
Thank you for your suggestions; I will try fix them asap.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests