Query: Edge transparency
-
I am building a Ruby plugin that uses Edge-s to draw polylines in layer=Tracks; they represent particle tracks. There are also Edge-s in ordinary solids in layer=Layer0.
I have a slider that varies the transparency of the Entity-s in Layer0, so I can see the particle tracks going through the solids. This requires a Style with Edge-s displayed by material (the particle tracks have different colors for different particle types).
Unfortunately, I cannot vary the transparency of Edge-s in layer0, and for some solids the dense Edge-s still obscure the particle tracks. Of course if I turn off viewing Edge-s, the tracks disappear, too.
Is there any way to get edges to become transparent, selectively (e.g. in Layer0 only, or by setting material)?
Is there any other way to draw polylines (a colored line that connects an array of Point3d-s)?
A workaround I might implement is that when the Layer0 transparency is set to 0.0, hide all of Layer0.
-
Instead of 'Edges' why not use 'Clines' ?
cl=entities.add_**cline**(pt0, pt1)
These are 'dotted' and they don't react with other geometry either.
You can even adjust their stipple-pattern with...
cl.stipple="."
etc...
See http://sketchup.com/intl/en/developer/docs/ourdoc/constructionline.php#stipple=
You can also do things like make them 'rays' - start.position + direct=vector ...
You can also toggle the visibility of clines [aka 'guides'] on/off in the View menu... -
Does it have to be with permanent geometry? Could it be enough to display these tracks using a custom Tool that the user activates? http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool.php
Tools will allow you to draw transparent edges - and polygons.
-
Those are both good ideas, and have taught me things I did not know about the SketchUp API. THANKS!
I have realized that I need to be able to select individual tracks with the mouse, so they must be Entities. Of course one selects only a single Edge of a multi-Edge track, but I can deal with that in a SelectionObserver. When any one of a track's Edge-s is selected, the code will select all of its Edge-s, and display information about the track (in a WebDialog). It already does something similar when a solid object is selected. Putting each track into its own group would let SketchUp select them all, but it looks ugly (the bounding box makes no sense for a track).
I have made the transparency slider hide the entire Solids layer when its value is less than 2%. Works great! That will also help in selecting tracks when they are inside a solid object.
Performance is good even with hundreds of solids controlled by the transparency slider -- SketchUp and Ruby are amazing!
-
You don't need entities to pick a path, you can use the PickHelper class to pick paths defined by a set of Point3d object (same objects you use to draw the path in Tool.draw).
API Docs:
http://www.sketchup.com/intl/en/developer/docs/ourdoc/pickhelper.phpI've tried to describe the class in a more visual manner:
http://www.thomthom.net/thoughts/2013/01/pickhelper-a-visual-guide/ -
@tjrob said:
Of course one selects only a single Edge of a multi-Edge track,
If the track is created as a curve (
entities.add_curve
) the native Selection tool will select the whole track even though you click on only one segment of it. -
@thomthom said:
If the track is created as a curve (
entities.add_curve
) the native Selection tool will select the whole track even though you click on only one segment of it.Great! I had not thought of that. Thanks!
I have it working with an array of Edge-s. I have since realized that I want to display track information related to where the user clicked on it (i.e. which Edge is clicked -- yes, the physics properties of a track vary along its length). I don't think I can do that with a Curve, as all its Edges get selected with one click.
-
Not is you want to use the native Select tool. But if you want to avoid observers and gain more control over your plugin's environment you could make your own tool.
Advertisement