Group Abstract Group Abstract

Message Boards Message Boards

Help moving lattices between Mathematica & Illustrator

I would like to have a workflow where I design lattices in Mathematica and modify them in Illustrator and then bring them back to Mathematica. Copying a graph from Mathematica and pasting it into Illustrator works pretty well. I am working with iGraphM installed to create regular lattices.

I can, for example, make this nice triangular lattice inside a hexagon. 7 X 7 X 7 triangular lattice

I would like to take out some struts in this lattice and bring it back to Mathematica and have the properties, such as adjacency and connections between points, that Wolfram recognized in the original to be preserved. I have tried a lot of things, but not of them work.

All that needs to be understood here are points and line segments, so it seems to me that it ought to work somehow.

Graphs I would like to bring back look like this: Pruned lattice.

Alternatively, is there a straightforward way to prune connections inside Mathematica, and have those prunings be reflected in adjacency matrices, etc.?

POSTED BY: Kathryn Cramer
2 Replies

I really like your idea. Thanks!

The Autodesk-related file formats seemed the closest to success.

POSTED BY: Kathryn Cramer

Depending on your hardware, this function may be useful

manipulatablegraph[graph_Graph] := 
 DynamicModule[{verts, vertcoords, edges, edgestates, edgehandlers}, 
  verts = VertexList@graph; 
  vertcoords = AbsoluteOptions[graph, VertexCoordinates]; 
  edges = EdgeList@graph; edgestates = Table[1, {e, edges}];
  edgehandlers = 
   MapIndexed[
    EventHandler[#1, {"MouseClicked" :> (edgestates[[First@#2]] = 
          Mod[edgestates[[First@#2]] + 1, 2])}] &, edges]; 
  Column@{Button["export selected edges", 
     Print[InputForm@
       Graph[verts, 
        edges[[Select[Range@Length@edges, edgestates[[#]] == 0 &]]], 
        vertcoords]]], 
    Dynamic@Graph[verts, edgehandlers, vertcoords, 
      EdgeStyle -> 
       Table[edges[[i]] -> {Thickness[.015], 
          If[edgestates[[i]] == 0, Blue, Lighter[Blue, .9]]}, {i, 
         Length@edges}]]}]
(*borrows heavily from https://mathematica.stackexchange.com/questions/51241/\
generating-eventhandler-using-table*)

Call it on your graph. You should be able to click edges to toggle them from light to solid blue. When you press 'export selected edges', it prints out the code for a graph whose edges are currently solid (intended for copying and pasting as Mathematica input).

If you don't insist on that particular edge subset (and don't want to select edges manually), you can coax Mathematica to output a spanning tree with a specified root node by iteratively calling FindSpanningTree and removing key edges.

I imagine Illustrator can export to many file formats. One of these might be easy to parse with Mathematica. There's always the nasty method of doing image processing on your result, and constructing graphs from morphology (it's surprisingly simple and robust).

POSTED BY: Adam Mendenhall
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard