Modifiying imported shapes in OpenSCAD - openscad

Given an STL file, OpenSCAD is able to import it:
import("file.stl");
I can also transform the result. However, when I try to do any openscad commands, the imported shape disappears:
translate([10,0,0])
import("Boat.stl");
cube(5);
Once the function call is added to any native shape, the boat disappears. Is there any way around this? I am trying to take a shape that has been sliced into pieces in netfabb, and create tabs so the the pieces fit precisely together for gluing.

Related

Overlapping Polygon Outline in Openscad

I am totally new to openscad.
I am trying to generate two overlapping polygons (2D). I would just like to observe the outlines of both shapes at the same time.
I have managed to generate two different shapes. Although the shapes overlap, the renderer appears to show the outline of the combined shape with the inner part is filled in with colour.
How might I achieve my goal if the shapes were simply two overlapping squares?
I would be glad to see your code to understand exactly what you're trying to describe.
In any case, you must know first that openscad have several rendering types:
the f5 one is the quicker and doesn't really calculates the final result, only its image on the screen (that's why you cannot export with it)
the f6 one which does all the calculation of the points of the mesh and then render it (that's what you do to export)
the debug ones that are similar to f5
I think f5 could be your solution but it will look a bit "glitchy" because of the superposition of the two shapes. The fact is that I don't think openscad is made for what you want to do because you can consider that all that you put in your script is in a big union() block so when you press f6 all the independent shapes are combined into one and I don't think there is a way to prevent that. I should add that I think that the 2D functions of openscad are probably made to be used with the extrude functions to make 3D volumes for which the overlapping doesn't have a lot of sense.

Import Adobe Illustrator bezier coordinates into Processing bezier() function

I'm working on a project where I can take my lettering pieces I do on illustrator with the pen tool and take the bezier point coordinates (curves and all) into processing bezier() function so I can individually manipulate the points with different formulas for animation.
I've tried using Adobe Point Exporter but it seems to only give the x, y coordinates without the curves. I've found a library for processing called Geomerative but I couldn't figure out how to export the coordinates into specific bezier points that I can import into bezier()
Thanks for taking the time to read this!
You can try export lettering into svg format and then use Processing loadShape function to load geometry into varible of type PShape:
https://processing.org/reference/loadShape_.html

How can I make dynamically generated terrain segments fit together Unity

I'm creating my game with dynamicly generated terrain. It is very simple idea. There are always three parts of terrain: segment on which stands a player and two next to it. When the player is moving(always forward) to the next segment new one is generated and the last one is cut off. It works wit flat planes, but i don't know how to do it with more complex terrain. Should I just make it have the same edge from both sides(for creating assets I'm using blender)? Or is there any other option? Please note that I'm starting to make games with unity.
It depends on what you would like your terrain to look like. If you want to create the terrain pieces in something external, like Blender, then yes all those pieces will have to fit together seamlessly. But that is a lot of work as you will have to create a lot of pieces that fit together for the landscape to remain interesting.
I would suggest that you rather generate the terrain dynamically in Unity. You can create your own mesh using code. You start by creating an object (in code), and then generating vertex and triangle arrays to assign to the object, for it to have a visible and sensible mesh. You first create vertices at specific positions and then add triangles that consist of 3 vertices at a time. If you want a smooth look instead of a low poly look, you will reuse some vertices for the next triangle, which is a little trickier.
Once you have created your block's mesh, you can begin to change your code to specify how the height of the vertices could be changed, to give you interesting terrain. As long as the first vertices on your new block are at the same height (say y position) as the last vertices on your current block (assuming they have the same x and z positions), they will line up. That said, you could make it even simpler by not using separate blocks, but by rather updating your object mesh to add new vertices and triangles, so that you are creating a terrain that is just one part that changes, rather than have separate blocks.
There are many ways to create interesting terrain. One of the most often used functions to generate semi-random and interesting terrain, is Perlin Noise. Another is his more recent Simplex noise. Like most random generator functions, it has a seed value, which you can keep track of so that you can create interesting terrain AND get your block edges to line up, should you still want to use separate blocks rather than a single mesh which dynamically expands.
I am sure there are many tutorials online about noise functions for procedural landscape generation. Amit Patel's tutorials are good visual and interactive explanations, here is one of his tutorials about noise-based landscapes. Take a look at his other great tutorials as well. There will be many tutorials on dynamic mesh generation as well, just do a google search -- a quick look tells me that CatLikeCoding's Procedural Grid tutorial will probably be all you need.

Visio (Re)naming shapes as 'sheet' when it should be circle, box, etc

This may seem pretty idiotic, but here goes: I'm making some networks in visio and I'm literally just cutting and pasting boxes and circles (changing the text) over and over again and adding connectors as appropriate. I have a macro that then sorts the shape texts based on whether it is a circle or box.
Every once in a while the macro will fail, not because there is a problem with the macro but because one of my shapes (boxes, circles, and even connectors) have been renamed by visio as a 'sheet'. For example, I copy 'Circle.18' and then paste it right back in, and instead of being 'Circle.19' this shape is 'Sheet.19'. This can happen when I copy & paste, or when I drag a new shape off the stencil. It appears to be totally random when this happens, but it messes up my subsequent macro operation so I would really like to stop visio from naming different shapes as 'sheet.xx'
Any ideas?
Is it possible to change the name of a shape in the shapesheet or anything?
Thanks in advance
I don't know how the naming works in Visio, and I don't rely on the names for macros.
In your case, distinguishing the geometries from one another is how I would identify shapes. So if it's a 2D shape, and it has a geometry section with 6 rows, it's probably a rectangle. If the geometry section has 2 rows, it's probably a circle.
However, I wouldn't necessarily let it get to the point where I'm going off of the shape geometry, unless I want whoever is using the macro to use whatever circle or box shapes they want. Instead, I would just provide a stencil with a box and a circle shape, and I would either put the different shapes on different layers, or just add a user cell with the type clearly defined. Then the macro would just look for those shapes specifically denoted as the type I'm interested in.

Identify different shapes drawn using UIBezierPath?

I am able to draw shapes using the UIBezierPath object. Now I want to identify different shapes drawn using this eg. Rectangle , Square , Triangle , Circle etc. Then next thing I want to do is that user should be able to select a particular shape and should be able to move the whole shape to different location on the screen. The actual requirement is even more complex , but If I could make this much then I can work out on the rest.
Any suggestion or links or points on how do I start with this is welcome . I am thinking of writing a separate view to handle every shape but not getting how do I do that..
Thank You all in advance !!
I recommend David Gelphman’s Programming with Quartz.
In his chapter “Drawing with Paths” he has a section on “Path Construction Primitives” which provides a crossroads:
If you use CGContextAddLineToPoint your user could make straight lines defined by known Cartesian points. You would use basic math to deduce the geometric shapes defined by those points.
If you use CGContextAddCurveToPoint your user could make curved lines defined by known points, and I’m pretty sure that those lines would run through the points, so you could still use basic math to determine at least an approximation of the types of shapes formed.
But if you use CGContextAddQuadCurveToPoint, the points define a framework outside of the drawn curve. You’d need more advanced math to determine the shapes formed by curves along tangents.
Gelphman also discusses “Path Utility Functions,” like getting a bounding box and checking whether a given point is inside the path.
As for moving the completed paths, I think you would use CGContextTranslateCTM.