Hello,
After attaching markers to a shape it is no longer possible to call the shape vertices and run the add attributes script below. I get Error: object of type 'NoneType' has no len ().
Our current process we create shapes on the non referenced model with markers attached, then reference the model and the shapes combined. After this process we can't draw on the model anymore as the shape's appear to be drawn at 0'0'0 coordinates. We then have to take off attach markers and draw on a camera image before attributes can be attached.
How do we draw shapes on a referenced model? and is it possible to call the shape vertices and add attributes to a shape with markers attached?
Thanks,
Abe
def add_channel_attributes():
import Metashape
chunk = Metashape.app.document.chunk
#loop chunk shapes
for shape in chunk.shapes:
#check for CHANNEL layer
if shape.group.label == 'CHANNEL':
#check shape is a polyline with only 2 vertices
if (shape.type == Metashape.Shape.Type.Polyline and len(shape.vertices) == 2):
channel_vertices = shape.vertices
#calculate dip and bearing, attach as attribute
shape.attributes['dip'] = str(calculate_dip(channel_vertices[1][0], channel_vertices[1][1], channel_vertices[1][2], channel_vertices[0][0], channel_vertices[0][1], channel_vertices[0][2]))
shape.attributes['bearing'] = str(calculate_bearing(channel_vertices[1][0], channel_vertices[1][1], channel_vertices[1][2], channel_vertices[0][0], channel_vertices[0][1], channel_vertices[0][2]))