trevorsandy / lpub3d

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

Stud Cylinder Color #702

Closed technicbasics closed 1 year ago

technicbasics commented 1 year ago

Subject

Request: I love the option "Stud Style", because there can also be changed the edge color of parts. This is very nice for black parts, to increase visibility. But it also has a small disadvantage: In the same setting, you can also adjust the Cylinder colors of the studs. It would be nice to be able to select these options individually as well. (Maybe with checkbox). 2023-04-14 17_22_33-LPub3D Preferences

Reason: I am currently working on a model that consists almost entirely of Technic parts and has many black parts. Therefore I want to change the Edge color, but not the Cylinder colors. You are probably wondering why? Well, I also put 1/2 pins in light gray, by coloring the cylinders they now look like they are black.

Setting: 0 - Plain 2023-04-14 17_08_55-Pistenbully 600 Polar V1 mpd - LPub3D v2 4 6 r144 (Release)

Setting: 6 - High contrast and matched black edge color 2023-04-14 17_10_10-Pistenbully 600 Polar V1 mpd - LPub3D v2 4 6 r144 (Release)

Solution: Either you could select the options individually as described above, or it would be possible to specify the colors not directly but in LDraw colors, e.g. to assign the color 16 to the cylinders so that they are not colored.

2023-04-14 17_23_08-LPub3D Preferences

By the way: 2.4.6r144 runs very stable until now!

trevorsandy commented 1 year ago

Thank you for your request. It is an excellent enhancement.

I’ll take a look.

Cheers,

trevorsandy commented 1 year ago

Note that while adding an enable flag for each colour option will add flexibility, it will not address the use case where both stud and 1/2 pin are present. In this case the stud cylinder colour behaviour will be on or off. This is so because when a high contrast stud style is selected, the default stud primitives (stud...dat) are replaced with an instance where the cylinder primitive (4-4cyli.dat) colour is hard coded to 4242 - e.g. 1 4242 0 -4 0 4 0 0 0 4 0 0 0 4 4-4cyli.dat.

Workaround

To override the stud behaviour when high-contrast stud style is selected, add a custom primitive part with the desired cylinder colour to your model. This primitive can be added directly to your model (inline primitive) file or placed in a 'custom part' folder.

As an example - for the stud2.dat primitive below, replace the colour code 4242 with 16, and append the resulting source to your model file.

0 Stud Open
0 Name: stud2.dat
0 Author: James Jessiman
0 !LDRAW_ORG Primitive
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt
0 BFC CERTIFY CCW
1 16 0 0 0 4 0 0 0 1 0 0 0 4 4-4edge.dat
1 16 0 0 0 6 0 0 0 1 0 0 0 6 4-4edge.dat
1 16 0 -4 0 4 0 0 0 1 0 0 0 4 4-4edge.dat
1 16 0 -4 0 6 0 0 0 1 0 0 0 6 4-4edge.dat
0 BFC INVERTNEXT
0 // to override the high-contrast stud cylinder colour, replace 4242 with your desired colour code
1 4242 0 -4 0 4 0 0 0 4 0 0 0 4 4-4cyli.dat
1 4242 0 -4 0 6 0 0 0 4 0 0 0 6 4-4cyli.dat
1 16 0 -4 0 2 0 0 0 1 0 0 0 2 4-4ring2.dat

Be sure Prefer Official Parts is unchecked in the Visual Editor Preferences.

Stud_Style+01

If you choose to place the modified stud in a custom folder, be sure the folder is added to the LDraw search paths using the Configuration menu action LDraw Search Directories....

Stud_Style+02

Cheers,

technicbasics commented 1 year ago

Thanks for explaining how the code works. That my solution does not work when both studs and 1/2 pins are present was clear to me. In my use case I want to adjust the edge colors of the black parts, but leave the studs and pins as they are. To create this behavior, I will switch back to the 0-PLain setting and adjust the edge color of the black parts in ldconfig.ldr.

Regards Johann

technicbasics commented 1 year ago

Have now changed the edge color in ldconfig.ldr and in LDCfgalt.ldr, but this has (unfortunately) no effect. :-( Which config file does the native renderer access? As far as I know, the LDView renderer could be tricked that way, or do I remember something wrong?

trevorsandy commented 1 year ago

In my use case I want to adjust the edge colors of the black parts, but leave the studs and pins as they are.

Indeed, if you do not desire the static-coloured studs available by default with high-contrast stud styles, then you will be better served by using an ldconfig file with the desired edge color settings - simply set the alternative ldconfig path in Preferences to an instance with the modified settings.

Have now changed the edge color in ldconfig.ldr and in LDCfgalt.ldr, but this has (unfortunately) no effect. :-( Which config file does the native renderer access?

Do not despair, by default, LPub3D uses the ldconfig file in the complete.zip archive library. It is not recommended to change the settings in this file (hence why it is 'hidden'), instead, simply set your modified ldconfig path as specified above.

Stud_Style+04

Cheers,

technicbasics commented 1 year ago

That make sense. Again thanks.

Regards from Austria

technicbasics commented 1 year ago

Hi Trevor First of all thanks for implementing this feature. But now the problem, the settings are not saved.. 2023-04-20 21_12_31-Einstellungen

after closing the window and reopen.. 2023-04-20 21_13_01-

It does not matter if a project is open or not, in both cases the settings are not applied.

What code would I need to insert in the Command window to force the settings in the project?

trevorsandy commented 1 year ago

Thank you for reporting this behaviour.

Making high-contrast stud style colour preferences optional is not yet complete.

This is why I have not updated this ticket with the new capability - as you can see, it is still in progress.

Once completed, the behaviour should be as expected.

Cheers,

technicbasics commented 1 year ago

Ah... OK.Thank you very much.

trevorsandy commented 1 year ago

Making high-contrast stud style colour preferences optional has been completed.

StudStyleColor

Cheers,