Converting lines?

Hello.
I wonder. Is there a script similar to _SetLinetype. Create dashed lines with Polycurve objects

The input value is:

  • length of line
  • distance between lines

This is relatively easy to do with Grasshopper…
image


DashedCurve.gh (4.8 KB)

Also possible to make fancier linetypes like ‘DashDot’


Thanks Mitch.

It will be more difficult with python code right?

Certainly - that GH definition took less than a minute to make. It has that nice “Dashed line” component. Two possibilities in Python - figure out your algorithm for splitting the curves into dashes - it’s not too hard but there is some code involved - or, use the Grasshopper component in the script via node-in-code.

Here is a sample python script with node-in-code - it’s almost as simple as the GH definition…

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import ghpythonlib.components as ghcomp

patt=[5.0,3.0]
crv=rs.GetObject("Select a curve",4,preselect=True)
lines,gaps=ghcomp.DashPattern(crv,patt)
if lines:
    line_segs=[sc.doc.Objects.AddCurve(line) for line in lines]
    group=rs.AddGroup()
    rs.AddObjectsToGroup(line_segs,group)
    rs.DeleteObject(crv)
    sc.doc.Views.Redraw()
1 Like

Hi, Mitch.

  • Is there a way to keep the current layer and select multiple objects

Sure, the above was just a proof of concept, not meant as a final finished script. Here’s something a bit more finished. Right now the pattern is still fixed in the script, I would like to use a PropertyListBox as a user interface, but this is not implemented on Mac, so it would only then work in Windows.

MakeDashedCurvesGHComp.py (1.2 KB)

You try to apply PropertyListBox to run on Windows. It would be pretty cool