1

I am using an XML reader, combined with the SimpleIDML module in python in an attempt to read and write to an IDML file. While doing this, I will need to read the geometric bounds (top, left, bottom, and right sides of an object) from said file. While looking through the XML file for the spread, I found this code:

<Properties>
  <PathGeometry>
    <GeometryPathType PathOpen="false">
      <PathPointArray>
        <PathPointType Anchor="159.92000000000002 -235.728" LeftDirection="157.85224590848 -235.728" RightDirection="161.98775409152 -235.728"/>
        <PathPointType Anchor="163.66400000000004 -239.47200000000004" LeftDirection="163.66400000000004 -237.40424590848" RightDirection="163.66400000000004 -241.53975409152002"/>
        <PathPointType Anchor="159.92000000000002 -243.21600000000007" LeftDirection="161.98775409152 -243.21600000000007" RightDirection="157.85224590848 -243.21600000000007"/>
        <PathPointType Anchor="156.176 -239.47200000000004" LeftDirection="156.176 -241.53975409152002" RightDirection="156.176 -237.40424590848"/>
      </PathPointArray>
    </GeometryPathType>
  </PathGeometry>
</Properties>

This appears to be the code for an Oval object within the IDML schema. From what I can see from the specs, these points define a Bezier curve. However, I am unfamiliar with Bezier curves and I don't know how I could convert this into geometric boundaries for the Oval itself.

Does anybody have a function in Python for deriving geometric bounds from these coordinates in inches? In addition, is there a way to convert a set of geometric bounds into this notation, if I want to move around/resize these ovals?

Update: Apparently each object has an "ItemTransform" property as well. This might be necessary for calculation?

RobC
  • 22,977
  • 20
  • 73
  • 80
  • Geometric bounds are rectangular. In this case, the anchors are in the middle of the rectangle’s sides. – user1754036 Jun 20 '19 at 09:48
  • 1
    Really? From what I saw, it looks like they're the endpoints of the rectangle – maninthecomputer Jun 20 '19 at 23:07
  • 2
    @maninthecomputer - you're right they're not _"anchors in the middle of a rectangles sides"_, The ``'s in your example form a circle (not rectangle) - think of them as each point located at N, E, S, W on a compass. Knowing the points form a circle requires a simple algorithm to compute it's geometric bounds. However the algorithm required needs to be more complex because 4 points can also form a shape similar to [this](https://www.algosome.com/articles/images/continuous-cubic-bezier-curve.jpg). – RobC Jun 21 '19 at 10:46
  • 1
    @maninthecomputer - If you don't get a suitable answer perhaps consider posting your question in [math.stackexchange.com](https://math.stackexchange.com/),. Also [this](https://stackoverflow.com/questions/2587751/an-algorithm-to-find-bounding-box-of-closed-bezier-curves) and [this](https://pomax.github.io/bezierinfo/#boundingbox) _maybe_ worth reading. – RobC Jun 21 '19 at 11:11

0 Answers0