Geometry
-
I wasn't planning on writing another part in this series, just yet, but then I got a little carried away with some refactoring work and decided it deserved a post of its own. I wasn't fully happy with the code in the last post. The DecomposeCurve() function simply did too much: it opened a curve, extracted the points we were interested in and then created "movement" strings for each segment connecting the points. So the function was just way too single-purpose, even if a number of the individual operations being performed could potentially have been of use elsewhere. So I…
-
Some of you may remember this series of posts from the beginning of the year (I also mentioned it in the last post). It showed how you might use AutoCAD and .NET (in this case via F#) to animate the Star Wars opening crawl for the first 6 movies. Back then I said I'd update the video series to include Star Wars Episode VII: The Force Awakens, once it was released. Today is that day… due to some bizarre accident of international scheduling, I got to see it two days ago, here in Switzerland. I took a few snaps of…
-
In the last post we saw how we could integrate an HTML and JavaScript palette hosting Cytoscape.js into AutoCAD to map progress made in a text adventure. In today's post we take the additional step of converting the graph data into AutoCAD geometry. To be clear, there's a bit more to this post than having fun mapping old-school interactive fiction inside AutoCAD: I can think of lots of scenarios where you might want to use a comparable tool to build a graph of data and lay it out manually before bringing the graph into AutoCAD as native geometry. But I'm…
-
I mostly despise jetlag but once in a while manage to harness it for something positive. I remember some great trips to Asia, waking up at strange times to experience the dawn, walking the streets and seeing everyday life starting up around me. These days I typically find jetlag to be a bit of a curse, but this weekend I ended up using it to tackle a fun challenge: generating maps for Z-machine games such as Zork inside AutoCAD. Something I mentioned in a recent blog post but was reminded of last Thursday while catching up with Christer Janson in…
-
This is a problem that developers have been struggling with for some time, and it came up again at the recent Cloud Accelerator: how to control the display of AutoCAD geometry at a per-viewport level, perhaps to implement your own "isolate in a viewport" command. It's certainly possible to control layer visibility at the viewport level, of course, but this is sometimes at odds with how users wish to use layers for their own purposes. An application may want to isolate geometry in a certain location from a number of layers, for instance, and it becomes cumbersome to hijack the…
-
A question came in by email, yesterday, and despite having a few mini-projects in progress that were spawned during last week's event in Prague, I couldn't resist putting some code together to address it. The developer wanted to purge zero-length geometry: the simplest way to solve the problem is to run "_-PURGE _Z" at the command-line, but I saw this more as an opportunity to create a simple helper that would loop through all the entities in a drawing and erase any meeting a specified condition. In this case it would be curves with a length less than the global…
-
This question came in via a comment, last week: Is it possible to get the point of intersection between a spline/3dpolyline and a plane surface? It turned out to be quite an interesting problem to solve. I started with brute force methods for the various curve types… For Polylines I checked linear segments against the plane (this is an intersection we can test), and for arc segments I broke these into linear segments and checked those, too. It all worked well with a high enough "resolution" for arc segments. Polyline3ds only have linear segments, so I could safely use the…
-
This is a follow-up to the post where we modified the size of selected text in a drawing, to make it fit its container. I received this comment last week: instead of selecting the nested entities one by one, is it possible to make a "selectall" selection ? It turns out that the question was related to a completely different post, but by the time I realised I'd already completed most of the work. It seems a very valid question for this topic, so that's fine. 🙂 Looping through all the text – some of which may be nested inside…
-
We started this series by looking at how to get the centroid of a region, and then how to create text that fits an arbitrary space. In this post we're going to wrap up by looking at the original question of how to resize block attributes to fit their container. The core algorithm is actually very similar to the code we saw in "space labelling" application: it's simply been refactored to be more general and forms the basis for both the previous and the new commands. Here's the C# code: using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.BoundaryRepresentation; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.EditorInput; using Autodesk.AutoCAD.Geometry;…
-
As mentioned in this recent post, I've been working on my AutoCAD I/O-driven web-site on and off for the last few weeks. Lately I've had to think beyond certain assumptions I'd made about its architecture, and I thought it worth sharing those thoughts here. The intention of the site is that you upload an image and then see some edge detection get performed on it, generating an engraving layer for a custom jigsaw puzzle. AutoCAD I/O gets used to generate a drawing that can drive a laser cutter, creating your 100% unique jigsaw puzzle. Basically making the world a better…