LDCad My second LDCad script :)


My second LDCad script :)
#1
I have "completed" (read: not perfectly) my second attempt at an LDCad script. It's attached below (change .txt to .lua).

This script scans an LDraw file for parts or submodels that are hidden by buffer exchange in the final display state. If it finds any, it comments out their type 1 reference lines in the code, so that they won't appear in LDView, Studio, or other programs that don't recognize the BUFEXCHG metas. (For my inner monologue on the development process, see this thread.)

The script only runs from the end of the file (i.e., the last step) so it shows the completed model. It's not meant to work on intermediate steps to show the visibility at any given build phase. It's more meant as a cleanup tool

Some functionality is missing in this version, but hopefully I can improve it in the future:
  • It's not recursive, so you have to run the script separately on any submodels that also use buffer exchange, as well as on the main file. (This because I'm not sure how to access all the subfile objects of an mpd file via the API.)
  • It modifies the current file, rather than writing a new file, so you'd want to save the changed file as a copy. Offering a choice here would be a nice feature.
  • Technically, it's not actually a toggle function since it doesn't work in reverse—you can't un-comment hidden lines with this script. Mainly this is because there's no way to tell a commented-out ref line generated by this script from one that's meant to be there already. (I suppose I could add a flag of some kind to the lines affected by the script.) Meanwhile, you can always just use LDCad's undo.

Please feel free to send me any test files, particularly those with complicated or unusual implementations of buffer exchange, or to test your own models. (In particular, there may be an issue with Wine, causing a crash when closing open files in LDCad.)


Attached Files
.txt   togBufEx.txt (Size: 1.42 KB / Downloads: 5)
Reply
« Next Oldest | Next Newest »



Messages In This Thread
My second LDCad script :) - by N. W. Perry - 2022-12-28, 14:43

Forum Jump:


Users browsing this thread: 1 Guest(s)