Function Repository Resource:

DashedTube

Source Notebook

Display a dashed tube in 3D graphics

Contributed by: Jaroslav Kysela

ResourceFunction["DashedTube"][{{x1,y1,z1},{x2,y2,z2},}]

represents a 3D dashed tube around the line joining a sequence of points.

ResourceFunction["DashedTube"][{pt1,pt2,},r]

represents a dashed tube of radius r.

ResourceFunction["DashedTube"][{pt1,pt2,},r,dash]

specifies a dashing dash of a tube.

ResourceFunction["DashedTube"][{pt1,pt2,},{r1,r2,}]

specifies a different tube radius at the position of each of the points pti.

ResourceFunction["DashedTube"][{{pt11,pt12,},{pt21,},},]

represents a collection of dashed tubes.

ResourceFunction["DashedTube"][curve,]

represents a dashed tube around the specified 3D curve.

Details and Options

ResourceFunction["DashedTube"] renders as a dashed circular 3D tube in Graphics3D.
The syntax of ResourceFunction["DashedTube"] mimics that of Tube, including its modifications using Arrow.
The radius of the tube can be specified either in absolute coordinates, or as Scaled[s].
If no explicit radius is specified, ResourceFunction["DashedTube"] uses a default radius of 0.05.
The dashing of ResourceFunction["DashedTube"] can be specified in two ways: either internally using the third argument, in which case the argument is a positive number or a list of such numbers; or externally using dashing primitives Dashed, Dotted, DotDashed, Dashing, and AbsoluteDashing.
In contrast to the default dashing behavior for Line, the absolute specification AbsoluteDashing is turned by ResourceFunction["DashedTube"] automatically into the relative one.
ResourceFunction["DashedTube"][{pt1,pt2,},] gives a tube consisting of a sequence of straight segments. It is equivalent to ResourceFunction["DashedTube"][Line[{pt1,}],].
The following curve specifications can be used:
Line[]piecewise line segments
BezierCurve[]composite Bezier curve
BSplineCurve[]B-spline curve
The following options can be used:
VertexColorsAutomaticvertex colors to be interpolated
"Each"Falsewhether to apply styling to each dashed segment separately
PlotPoints30initial number of sampling points of the input curve
MaxIterations20maximum number of subdivisions during the sampling
To create a dashed line that follows the input curve specification, the algorithm first samples the input curve. Once the sufficiently fine sampling is found, the dashing specification is used to assess which sampling points belong to which dashed segment. The output of ResourceFunction["DashedTube"] consists of a collection of properly styled Tube lines, each corresponding to a dashed segment.
If a segment contains only a single point, Ball is used centered around this point, instead of Tube.
The number of initial sample points is given by PlotPoints. If this number is not sufficient, the sampling is refined iteratively until sufficient number is reached or MaxIterations number of iterations is hit.
Because of the sampling procedure, aliasing artifacts may occur, where different segments have varying lengths, even though the dashing specification tells them to be of the same length.
By default, the joins between tube segments are rounded. Different forms of joining between tube segments can be specified using JoinForm.
By default, the ends of the tube are rounded. Different caps for the tube can be specified using CapForm. CapForm[None] specifies that the end of the tube should be left open.
Colors and other material properties of tubes can be specified using color directives as well as Specularity and Glow. Tubes can be specified as transparent using Opacity directives.

Examples

Basic Examples (8) 

Create a simple dashed tube:

In[1]:=
Graphics3D[ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}]]
Out[1]=

A dashed tube along a curve:

In[2]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BSplineCurve[{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {3, 4, 1}}]]]
Out[2]=

A dashed tube with radius 0.1:

In[3]:=
Graphics3D[{Green, ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, 0.1]}]
Out[3]=

A dashed tube with dashing {0.2,0.05}:

In[4]:=
Graphics3D[
 ResourceFunction[
  "DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .04, {.2, .05}]]
Out[4]=

Add an Arrow:

In[5]:=
Graphics3D[{Arrowheads[.2], Arrow[ResourceFunction[
    "DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .03, .11]]}]
Out[5]=

Differently styled dashed tubes:

In[6]:=
t = ResourceFunction[
   "DashedTube"][{.8 {-1, -1, -1}, {0, 0, 1}, {1, 1, -1}}, 0.15, .45];
In[7]:=
{Graphics3D[{Red, t}], Graphics3D[{CapForm["Square"], t}], Graphics3D[{JoinForm["Bevel"], t}]}
Out[7]=

Gradient coloring:

In[8]:=
curve = BSplineCurve[{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {3, 4, 1}}];
In[9]:=
Graphics3D[
 ResourceFunction["DashedTube"][curve, 0.2, 0.5, VertexColors -> {Red, Green, Blue, Purple}]]
Out[9]=

Gradient coloring for each segment independently:

In[10]:=
curve = BSplineCurve[{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {3, 4, 1}}];
In[11]:=
Graphics3D[
 ResourceFunction["DashedTube"][curve, 0.2, 0.5, VertexColors -> {Red, Green, Blue, Purple}, "Each" -> True]]
Out[11]=

Scope (20) 

Tube Specification (4) 

Single dashed tube segment:

In[12]:=
Graphics3D[ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}]]
Out[12]=

Multiple connected dashed tube segments:

In[13]:=
Graphics3D[
 ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}, {4, 0, 0}}]]
Out[13]=

DashedTube can take a line or curve argument:

In[14]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/3a0ac1ed-6eac-46cc-9dc8-2a6b9ae564cd"]
Out[14]=

Multiple disconnected dashed tube segments:

In[15]:=
s = {{0, 0, 0}, {2, 1, 1}, {4, 0, 0}};
In[16]:=
{Graphics3D[ResourceFunction["DashedTube"][{s, s + 1}]], Graphics3D[
  ResourceFunction["DashedTube"][BezierCurve[{s, s + 1, s + 2}]]], Graphics3D[
  ResourceFunction["DashedTube"][
   BSplineCurve[{s, s + 1, s + 2, s + 3}]]]}
Out[16]=

Coordinate Specification (2) 

Use standard coordinates:

In[17]:=
{Graphics3D[ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}]], Graphics3D[
  ResourceFunction["DashedTube"][
   BSplineCurve[{{0, .2, 0}, {1, .8, 1}}]], Axes -> True]}
Out[17]=

Use Scaled coordinates:

In[18]:=
{Graphics3D[
  ResourceFunction[
   "DashedTube"][{Scaled[{0, 0, 0}], Scaled[{2, 1, 1}]}]], Graphics3D[
  ResourceFunction["DashedTube"][
   BSplineCurve[{Scaled[{0, .2, 0}], Scaled[{1, .8, 1}]}]], Axes -> True]}
Out[18]=

Radius Specification (3) 

Dashed tubes with different radii:

In[19]:=
s = {{-1, -1, -1}, {1, 1, 1}};
In[20]:=
Table[Graphics3D[
  ResourceFunction["DashedTube"][s, i]], {i, {.05, .1, .2}}]
Out[20]=

Radii can also be specified at vertices:

In[21]:=
{Graphics3D[{CapForm[None], ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, {1, 2}]}], Graphics3D[{CapForm["Round"], ResourceFunction[
    "DashedTube"][{{0, 0, 0}, 2 {-6, 4, 10}}, {2, 1}, {3, 2}]}]}
Out[21]=

Dashed tubes with scaled radii:

In[22]:=
s = {{-1, -1, -1}, {1, 1, 1}};
In[23]:=
Table[Graphics3D[ResourceFunction["DashedTube"][s, Scaled[i]], PlotRange -> 1.5], {i, {.01, .02, .04}}]
Out[23]=

Dashing Specification (6) 

Use uniform dashing specified by 0.1:

In[24]:=
Graphics3D[
 ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, 0.05, 0.1]]
Out[24]=

Use non-uniform dashing {0.25,0.1}:

In[25]:=
Graphics3D[
 ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, 0.05, {0.25, 0.1}]]
Out[25]=

Use more complicated dashing {0.25,0.1,0.05}:

In[26]:=
Graphics3D[
 ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, 0.05, {0.25, 0.1, 0.05}]]
Out[26]=

Dashing can also be specified outside DashedTube using Dashed, Dotted, DotDashed, Dashing, and AbsoluteDashing primitives:

In[27]:=
{Graphics3D[{Dashed, ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01]}], Graphics3D[{Dashing[.05], ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01]}]}
Out[27]=

AbsoluteDashing[s] is internally automatically replaced with s:

In[28]:=
{Graphics3D[{AbsoluteDashing[.05], ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01]}], Graphics3D[{ResourceFunction[
    "DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01, 0.05]}]}
Out[28]=

When both the external modifier such as Dashed and the explicit dashing specification inside DashedTube is used, the latter gets precedence:

In[29]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/eb64a071-7144-46c3-8591-e563491a13cf"]
Out[29]=

Tube Styling (5) 

Colored dashed tubes:

In[30]:=
l = ResourceFunction[
   "DashedTube"][{{1, 1, -1}, {2, 2, 1}, {3, 3, -1}, {4, 4, 1}}, 0.1, .5];
In[31]:=
Table[Graphics3D[{c, CapForm[None], JoinForm[None], l}], {c, {Red, Green, Blue, Yellow}}]
Out[31]=

Different properties can be specified for the front and back faces using FaceForm:

In[32]:=
Graphics3D[{FaceForm[Yellow, Blue], ResourceFunction["DashedTube"][10 {{0, 0, -1}, {0, 0, 1}}, 1, 2]}, PlotRange -> {{-1, 1}, {-.8, 1}, {-10, 7}}]
Out[32]=

Dashed tube caps can be specified using CapForm:

In[33]:=
Table[Graphics3D[{CapForm[cap], ResourceFunction["DashedTube"][{{-1, 1, -1}, {1, -1/2, 1}}, 0.7, 0.5]}, PlotRange -> 2, PlotLabel -> Row[{cap}], Boxed -> False], {cap, {None, "Butt", "Round", "Square"}}]
Out[33]=

Joining of dashed tube segments can be specified using JoinForm:

In[34]:=
Table[Graphics3D[{JoinForm[j], ResourceFunction[
    "DashedTube"][{0.6 {-1, -1, -1}, {0, 0, 1}, {1, 1, -1}}, 0.3, 0.7]}, PlotRange -> 1.5, PlotLabel -> Row[{j}], Boxed -> False], {j, {None, "Bevel", "Round", "Miter"}}]
Out[34]=

Colors can be specified at vertices using VertexColors:

In[35]:=
Graphics3D[{ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.1, VertexColors -> {Red, Green}]}]
Out[35]=

Options (10) 

VertexColors (2) 

Specify color gradient over the tube:

In[36]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BSplineCurve[{{0, 0, 0}, {0, 2, 1}, {-1, 0, 1}}], VertexColors -> {Red, Green, Blue}]]
Out[36]=

Use the same gradient for each segment separately:

In[37]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BSplineCurve[{{0, 0, 0}, {0, 2, 1}, {-1, 0, 1}}], VertexColors -> {Red, Green, Blue}, "Each" -> True]]
Out[37]=

Each (2) 

By default, the styling as well as Arrow are applied to the DashedTube globally:

In[38]:=
g1 = Graphics3D[
   ResourceFunction["DashedTube"][
    BSplineCurve[{{0, 0, 0}, {0, 2, 1}, {-1, 0, 1}}], 0.05, {0.2, 0.1}, VertexColors -> {Red, Green, Blue}]];
g2 = Graphics3D[{Arrowheads[.2], Arrow@ResourceFunction["DashedTube"][
      BSplineCurve[{{-1, 0, 1}, {0, 2, 1}, {0, 0, 0}}], 0.05, {0.2, 0.25}]}];
{g1, g2}
Out[38]=

To apply the styling and arrows to each segment separately, set "Each" to True:

In[39]:=
g1 = Graphics3D[
   ResourceFunction["DashedTube"][
    BSplineCurve[{{0, 0, 0}, {0, 2, 1}, {-1, 0, 1}}], 0.05, {0.2, 0.1}, VertexColors -> {Red, Green, Blue}, "Each" -> True]];
g2 = Graphics3D[{Arrowheads[.15], Arrow@ResourceFunction["DashedTube"][
      BSplineCurve[{{-1, 0, 1}, {0, 2, 1}, {0, 0, 0}}], 0.05, {0.2, 0.25}, "Each" -> True]}];
{g1, g2}
Out[39]=

To apply an arrow to each segment of a DashedTube that has a global styling, use a simple replacement:

In[40]:=
gr = {Arrowheads[.15], ResourceFunction["DashedTube"][
    BSplineCurve[{{-1, 0, 1}, {0, 2, 1}, {0, 0, 0}}], 0.05, {0.2, 0.25}, VertexColors -> {Red, Green, Blue}]};
In[41]:=
Graphics3D[gr /. x_Tube :> Arrow[x]]
Out[41]=

PlotPoints (3) 

For some combinations of curves and dashing specifications, the sampling process may introduce aliasing artifacts or cusps:

In[42]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BSplineCurve[{{0, 0, 0}, {0, 5, 0}, {1, 1, -1}}], 0.05, {0.5, 0.2}, PlotPoints -> 20, MaxIterations -> 1]]
Out[42]=

Increase the initial number of sampling points:

In[43]:=
gr = Graphics3D[
  ResourceFunction["DashedTube"][
   BSplineCurve[{{0, 0, 0}, {0, 5, 0}, {1, 1, -1}}], 0.05, {0.5, 0.2},
    PlotPoints -> 150, MaxIterations -> 1]]
Out[43]=

Manual setting of the sampling number may lead to excessive number of resulting points that make up the tube segments:

In[44]:=
Total@Cases[gr[[1]], Tube[pts_, r___] :> Length[pts], Infinity]
Out[44]=

MaxIterations (3) 

For some combinations of curves and dashing specifications, the sampling process may introduce aliasing artifacts or cusps:

In[45]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BSplineCurve[{{0, 0, 0}, {0, 5, 0}, {1, 1, -1}}], 0.05, {0.5, 0.2}, PlotPoints -> 20, MaxIterations -> 1]]
Out[45]=

Increase the number of division steps in the sampling process to adaptively find an optimum number of sampling points:

In[46]:=
gr = Graphics3D[
  ResourceFunction["DashedTube"][
   BSplineCurve[{{0, 0, 0}, {0, 5, 0}, {1, 1, -1}}], 0.05, {0.5, 0.2},
    PlotPoints -> 10, MaxIterations -> 10]]
Out[46]=

The number of points that make up the tube segments is chosen to be minimum and still sufficient:

In[47]:=
Total@Cases[gr[[1]], Tube[pts_, r___] :> Length[pts], Infinity]
Out[47]=

Applications (3) 

Plot a parametric space curve and replace the curve with a dashed tube:

In[48]:=
ParametricPlot3D[{Sin[u], Cos[u], u/10}, {u, 0, 20}, PlotStyle -> Orange, PlotRange -> All] /. Line[pts_, rest___] :> ResourceFunction["DashedTube"][pts, 0.1, 0.2, rest, MaxIterations -> 250]
Out[48]=

DashedTube can be used with Arrow for dashed 3D arrows:

In[49]:=
Graphics3D[{Arrowheads[.2], Blue, Arrow[ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.05, {0.35, 0.3}, VertexColors -> {Red, Blue}]]}]
Out[49]=

Define a 3D coordinate system with dashed axes:

In[50]:=
Graphics3D[{Dashing[{0.07, .05}], Gray, ResourceFunction[
   "DashedTube"][{{{-1, 0, 0}, {1, 0, 0}}, {{0, -1, 0}, {0, 1, 0}}, {{0, 0, -1}, {0, 0, 1}}}, .02]}]
Out[50]=

Properties and Relations (5) 

When no dashing is specified, the DashedTube gives identical results to Tube:

In[51]:=
{Graphics3D[
  ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.02, 0]], Graphics3D[Tube[{{0, 0, 0}, {2, 1, 1}}, 0.02]]}
Out[51]=

Use Arrow with DashedTube to get a dashed 3D arrow:

In[52]:=
Graphics3D[{Arrowheads[.1], Arrow[ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.03, .25]]}]
Out[52]=

Use Dashing specification outside DashedTube to set its dashing:

In[53]:=
Graphics3D[{Dashing[.12], ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.02]}]
Out[53]=

Use dashing primitives Dashed, Dotted, and DotDashed to specify the dashing:

In[54]:=
Table[Graphics3D[{dashing, ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01]}, ImageSize -> Medium], {dashing, {Dashed, Dotted, DotDashed}}]
Out[54]=

One can readily mimic the action of DashedTube, provided the uniformity of the dashing is not an issue:

In[55]:=
dashedLineSimple[curve_, rad_, dashing_] := Module[{pts, dashlist = dashing, fun = curve},
  If[Head[dashlist] =!= List, dashlist = {dashlist}];
  dashlist = Join @@ Table[dashlist, 1/Total[dashlist]];
  dashlist = Join[{0.}, Most@Accumulate[dashlist]]; fun = fun /. {BezierCurve -> BezierFunction, BSplineCurve -> BSplineFunction}; pts = Partition[Table[fun[n], {n, dashlist}], 2][[;; ;; 2]];
  Tube[#, rad] & /@ pts
  ]
In[56]:=
curve1 = BezierCurve[{{0, 0, 0}, {1/2, 1/2, 1}, {1, 1, 1}}];
curve2 = BezierCurve[{{0, 0, 0}, {5, 10, 1/2}, {1, 1, 2}}];
{Graphics3D[dashedLineSimple[curve1, .01, .05]], Graphics3D[dashedLineSimple[curve2, .05, {0.06, 0.001}]]}
Out[56]=

DashedTube tries to keep the dashing uniform:

In[57]:=
{Graphics3D[
  ResourceFunction["DashedTube"][curve1, .01, {0.15, 0.25}]], Graphics3D[ResourceFunction["DashedTube"][curve2, .05, {0.8, 0.4}]]}
Out[57]=

Possible Issues (6) 

In some cases, aliasing artifacts may occur:

In[58]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BezierCurve[{{0, 0, 0}, {1/2, 1/2, 1}, {1, 1, 1}}], .02, {.01, .06}]]
Out[58]=

Increase the number of sampling iterations:

In[59]:=
Graphics3D[
 ResourceFunction["DashedTube"][
  BezierCurve[{{0, 0, 0}, {1/2, 1/2, 1}, {1, 1, 1}}], .02, {.01, .06},
   MaxIterations -> 50]]
Out[59]=

From the way how the built-in arrows are handled, undesired behavior may occur when DashedTube is used with Arrow:

In[60]:=
Graphics3D[{Arrowheads[.3], Arrow[ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.1, {0.2, 0.2}, VertexColors -> {Red, Blue}]]}]
Out[60]=

This effect can be mitigated by removing several last segments from the dashed tube:

In[61]:=
gr = {Arrow[
    ResourceFunction["DashedTube"][{{0, 0, 0}, {2, 1, 1}}, 0.1, {0.2, 0.2}, VertexColors -> {Red, Blue}]]};
segments = Cases[gr, {{_, _Tube} ..}, Infinity];
arrows = Cases[gr, {{_, _Arrow} ..}, Infinity];
In[62]:=
Graphics3D[{Arrowheads[.3], segments[[;; , ;; -3]], arrows}]
Out[62]=

When Arrow is used together with VertexColors and "Each"True, the color gradients are ignored and only the last color is used for each segment:

In[63]:=
t = ResourceFunction[
   "DashedTube"][{{0, 0, 0}, {2, 1, 1}, 2 {2, 1, 1}}, 0.1, 1, VertexColors -> {Red, Yellow, Blue}, "Each" -> True];
In[64]:=
{Graphics3D[{t}, ImageSize -> Medium], Graphics3D[{Arrowheads[.1], Arrow@t}, ImageSize -> Medium]}
Out[64]=

DashedTube makes no difference between the dashing specified using absolute and standard units:

In[65]:=
{Graphics3D[{AbsoluteDashing[.05], ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01]}], Graphics3D[{Dashing[.05], ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}, .01]}]}
Out[65]=

Compare this with the default behavior for Line:

In[66]:=
{Graphics3D[{Thick, AbsoluteDashing[.05], Line[{{0, 0, 0}, {1, 1, 1}}]}], Graphics3D[{Thick, Dashing[.05], Line[{{0, 0, 0}, {1, 1, 1}}]}]}
Out[66]=

When JoinForm is set to "Miter", the result may not be discernible from that for "Bevel":

In[67]:=
tube = ResourceFunction[
   "DashedTube"][{{-1, -1, -1}, {0, 0, 1}, {1, 1, -1}}, 0.3, {1.2, 0.8}, PlotPoints -> 10, MaxIterations -> 5];
Table[Graphics3D[{JoinForm[j], tube}, PlotRange -> 1.5, PlotLabel -> Row[{j}], Boxed -> False], {j, {None, "Bevel", "Round", "Miter"}}]
Out[67]=

The reason is that the dashed tube consists of many points and the joints are effectively smooth, resulting in no visible cusp:

In[68]:=
pts = Cases[{tube}, Tube[pts_, r___] :> pts, Infinity];
In[69]:=
Table[Graphics3D[{Point /@ pts, Opacity[.5], JoinForm[j], Tube[pts, 0.3]}, ImageSize -> Medium, PlotLabel -> j], {j, {"Bevel", "Miter"}}]
Out[69]=

When only the essential points are retained, one recovers the expected behavior:

In[70]:=
ptsr1 = pts[[1]];
ptsr2 = pts[[2, {1, 6, -1}]];
ptsr3 = pts[[3]];
In[71]:=
Table[Graphics3D[{Point /@ {ptsr1, ptsr2, ptsr3}, Opacity[.5], JoinForm[j], Tube[{ptsr1, ptsr2, ptsr3}, 0.3]}, ImageSize -> Medium, PlotLabel -> j], {j, {"Bevel", "Miter"}}]
Out[71]=

The external dashing specification has to be in the same List with DashedTube, otherwise it is ignored:

In[72]:=
Graphics3D[{Dashing[{.1, .5, .2}],
  {Red, ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}]},
  {Green, ResourceFunction["DashedTube"][{{1, 0, 0}, {-1, 1, 1}}]}
  }]
Out[72]=

Flatten the whole list:

In[73]:=
Graphics3D[{Dashing[{.1, .5, .2}],
  Red, ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}],
  Green, ResourceFunction["DashedTube"][{{1, 0, 0}, {-1, 1, 1}}]
  }]
Out[73]=

Alternatively, put the Dashing construct into each sublist:

In[74]:=
Graphics3D[{
  {Dashing[{.1, .5, .2}], Red, ResourceFunction["DashedTube"][{{0, 0, 0}, {1, 1, 1}}]},
  {Dashing[{.1, .5, .2}], Green, ResourceFunction["DashedTube"][{{1, 0, 0}, {-1, 1, 1}}]}
  }]
Out[74]=

Neat Examples (3) 

Dashed tube curves with interpolated radii:

In[75]:=
Graphics3D[{CapForm[None], ResourceFunction["DashedTube"][
   BSplineCurve[{{0, 0, -1}, {0, 0, -.5}, {0, 0, 0}, {0, 0, 1}, {0, 0,
       15}, {0, 0, 20}, {0, 0, 25}, {0, 0, 32}, {0, 0, 35}}], {6, 6.5,
     6, 3.2, 12, 4, 2, 2.4, 3.5}, 0.8]}]
Out[75]=

Using random radii:

In[76]:=
pts = N[Table[{u, 5 Cos[u u], 5 Sin[u u]}, {u, 1, 10, .3}]];
In[77]:=
Graphics3D[{
  {Red, ResourceFunction["DashedTube"][
    BSplineCurve[pts, SplineDegree -> 3], .5 RandomReal[1, 31], {2, 1}, PlotPoints -> 250]},
  {Green, ResourceFunction["DashedTube"][
    BSplineCurve[pts, SplineDegree -> 8], .5 RandomReal[1, 31], {2, 1}, PlotPoints -> 250]}
  }, PlotRange -> All]
Out[77]=

Create a curve composed of balls:

In[78]:=
pts = N[Table[{3 u, 5 Cos[u u], 5 Sin[u u]}, {u, 1, 5, .2}]];
In[79]:=
Graphics3D[{Dashing[{.1, 1}], Red, ResourceFunction["DashedTube"][BSplineCurve[pts, SplineDegree -> 3],
    Reverse@Subdivide[0.1, .5, Length[pts] - 1], PlotPoints -> 1500, MaxIterations -> 1]}]
Out[79]=

Publisher

Jaroslav Kysela

Version History

  • 1.0.0 – 22 November 2021

Related Resources

Author Notes

DashedTube does not differentiate between AbsoluteDashing and Dashing options.
Related bugs:
For certain choices of values for Arrowheads, radius, and PlotRange, the behavior of Arrow[Tube[]] very much resembles the behavior discussed in https://community.wolfram.com/groups/-/m/t/1302365. See e.g. the output of Graphics3D[{Arrowheads[0.15],Arrow@Tube[0.05{{0,0,0},{1,0,0}},0.05]},PlotRange1]
Arrow ignores color specification defined by VertexColors inside Tube. Compare outputs of Graphics3D[{Arrowheads[.5],Tube[{{0,0,0},{1,1,1}},.1,VertexColors{RGBColor[1,0,0],RGBColor[0,0,1]}]}] and Graphics3D[{Arrowheads[.5],Arrow@Tube[{{0,0,0},{1,1,1}},.1,VertexColors{RGBColor[1,0,0],RGBColor[0,0,1]}]}].

License Information