Forum

Author Topic: Draw rectangle polygon  (Read 3438 times)

photo_man

  • Newbie
  • *
  • Posts: 10
    • View Profile
Draw rectangle polygon
« on: June 26, 2019, 01:37:10 PM »
Hi, I am drawing a polygon on my DEM and I want it to be a perfect rectangle. But, my selections are imperfect and the edges are slanted.

Is there any way to force the shape to be a rectangle?

Thanks!

JMR

  • Hero Member
  • *****
  • Posts: 502
    • View Profile
Re: Draw rectangle polygon
« Reply #1 on: June 26, 2019, 04:21:24 PM »
draw it on cad and import to your project

photo_man

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Draw rectangle polygon
« Reply #2 on: June 27, 2019, 07:41:19 PM »
Thanks JMR, but I'm looking for a way to do this in PhotoScan. I don't want to add another program to my workflow.

Any other ideas?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: Draw rectangle polygon
« Reply #3 on: June 27, 2019, 09:10:21 PM »
Hello photo_man,

If you are drawing the shapes in Ortho view mode, holding SHIFT key would help to draw the straight lines.

Alternative way could be a custom Python script. For example, you draw the point shapes that define the opposite corners of your rectangular area, select them and run the script which creates a new polygonal shape automatically.


The following script should work in such way, providing that coordinate system is Local Coordinates or some projected system (would not work correctly for WGS84):
Code: [Select]
import Metashape

chunk = Metashape.app.document.chunk

shapes = [shape for shape in chunk.shapes if (shape.type == Metashape.Shape.Point and shape.selected)]
if len(shapes) != 2:
print("Select exactly two point shapes!")
Metashape.app.messageBox("Select exactly two point shapes!")
else:
new_shape = chunk.shapes.addShape()
new_shape.type = Metashape.Shape.Polygon
new_shape.has_z = False
new_shape.vertices = [shapes[0].vertices[0], Metashape.Vector([shapes[0].vertices[0].x, shapes[1].vertices[0].y]), shapes[1].vertices[0], Metashape.Vector([shapes[1].vertices[0].x, shapes[0].vertices[0].y])]
print("New rectangular shape created.")
Metashape.app.messageBox("New rectangular shape created.")
« Last Edit: June 27, 2019, 09:28:27 PM by Alexey Pasumansky »
Best regards,
Alexey Pasumansky,
Agisoft LLC

photo_man

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Draw rectangle polygon
« Reply #4 on: June 28, 2019, 09:30:56 PM »
Perfect, thank you!