trevorsandy / lpub3d

An LDraw™ editor for LEGO® style digital building instructions.
https://trevorsandy.github.io/lpub3d/
130 stars 19 forks source link

Custom parts makes BOM crash LPub3D #730

Closed snakebyte73 closed 1 year ago

snakebyte73 commented 1 year ago

Subject

When I use a custom hose part I made LPub3D crashes when generating the BOM. It does show the custom hose in the step PLI. The custom hose is just a 2L hose I am using Native renderer If i switch to LDView renderer instead of Native it does not fail. But it is a lot slower than Native renderer The dat file is copied to this folder: C:\Users\Public\Documents\LDraw\Unofficial\Hoses\ The folder is part of the search dirs in LPub3D

Content of the file: DSB_IC3_8W_Antenna_2L.dat

0 DSB_IC3_8W_Antenna_2L 0 Name: DSB_IC3_8W_Antenna_2L.dat 0 Author: Knud Ahrnell Albrechtsen [Snakebyte] 0 !LDRAW_ORG Unofficial_Part 0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt 0 BFC CERTIFY CCW 0 !CATEGORY Custom Hoses 0 !KEYWORDS Train, Diesel Engine, DSB IC3, Hose

0 SYNTH BEGIN TECHNIC_FLEX-SYSTEM_HOSE 16 0 SYNTH SHOW 0 GHOST 0 MLCAD HIDE 1 71 0 10 -9 1 0 0 0 1 0 0 0 1 LS01.dat 0 GHOST 0 MLCAD HIDE 1 71 0 -29 -9 1 0 0 0 1 0 0 0 1 LS01.dat 0 SYNTH SYNTHESIZED BEGIN 1 16 0 10 -9 1 0 0 0 -39 0 0 0 1 LS50.dat 0 SYNTH SYNTHESIZED END 0 SYNTH END 0 0 NOFILE 0

Environment

Configuration

Logs

Screenshots

LPub_Settings.zip TestProject 3D.zip

Steps to reproduce

Add the custom part to the instructions and go to BOM. Provide a sample mpd/ldr file that reproduces the problem.

Expected behaviour

Create the BOM containing custom parts

Actual behaviour

Error message and the crash

Workaround

Share your work around if available

Solution suggestion

Share your opinion on how to achieve the expected behaviour

trevorsandy commented 1 year ago

Thank you for reporting this behaviour.

I'll take a look.

Cheers,

trevorsandy commented 1 year ago

What is the purpose of the numerous spurious INSERT PICTURE lines and empty STEP commands in the example model file you provided ?

For example there are many steps with the following configuration:

0 !LPUB INSERT  PICTURE "T:/Standard Docs/Instructions By.png" SCALE 0.82107 OFFSET -9.77465e-5 0.888859
0 STEP

Moreover, the image file 'By.png' was not provided so each of these lines will produce and error message.

There are also many CALLOUT DIVIDER commands without any CALLOUT BEGIN (and END) commands.

Can you provide a properly configured example model file ?

Cheers,

snakebyte73 commented 1 year ago

The Insert picture is used for this billede You can jyst remove the picture from the steps The many empty steps is just missing cleanup after testing what made LPub crash :)

snakebyte73 commented 1 year ago

I cleaned up the test file and it still fails: TestProject 3D.zip

trevorsandy commented 1 year ago

Excellent. Many thanks.

Indeed, I have found the problem which was because of the naming convention you are using for the custom parts. An underscore _ in the name is an invitation for problems as LPub3D is using this character as a delimiter. While the _ character is treated for most use cases, there as obviously still edge cases that from time-to-time will present with unexpected behaviour. Your safest bet is to use hungarian notation as a naming convention for parts - e.g. dsbIc38wAntenna1L.dat

Also in the custom part code above, there is a spurious NOFILE command which is not needed for parts.

Cheers,

snakebyte73 commented 1 year ago

Thanks That did the trick :) After correcting the parts as described by you and "Archiving Unofficial Parts" and a restart of LPub3D it works correctly I am a programmer myself and a little puzzled that an underscore can cause such problems ?? Usually I use underscores to prevent whitespace problems :D In all the time i have used LPub3D this has never been a problem berfore??

But if it works, no problem, I will start renaming all my custom parts :D

trevorsandy commented 1 year ago

I've updated the BOM render behaviour to support parts with underscore(s) and/or dash(es) in the name.

CustomParts730

Cheers,

snakebyte73 commented 1 year ago

Thanks again :) And I think it is awesome all the time you invest in this program.