[Tex/LaTex] Easy way to do several line styles on one path using TikZ

3dpathstikz-pgf

I'm drawing a lot of 3D pictures for school using 3D-plot for TikZ.
I like it when the lines that are inside or behind an object, eg. the ones that shouldn't be visible to be thinner than the lines that are.

For instance: A cube should look like this:

cube

where the dashed lines could just be thinner than the rest..

To get this type of 3D I would normally draw the entire cube (all the lines) with the very thin option. Then I'd copy the lines that should be very thin (the ones that aren't dashed in the figure) and let TikZ redraw them using the thinoption (it's obsolete I know) or the thick option.

Since this isn't a clean way to work, what are your suggestions?

I'd like to see something like:

\draw[tdplot_main_coords,thick] (0,0,0)--(0,1,0){ [very thin] --}(0,0,1)-- ... ;

Where I can just select part of a path and give it the right options (overriding the general options).

Best Answer

While there is the scopes TikZ library which allows you to use in-path scopes, many of the drawing options are global to the drawing path. Things like color, thickness and drawing pattern (e.g. solid vs. dashes) can only be applied to the whole path. The reason for this comes from the underlying graphic system (PS or PDF) and PGF/TikZ can't do much about it.

If you want to draw lines with different settings you will have to do so with two or more drawing commands. Note that TikZ has the ability to draw material into the background, i.e. behind previous drawn material. Enclose such commands between \begin{pgfonlayer}{background} ... \end{pgfonlayer}.