Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Abe Whaanga

Pages: [1]
1
Python and Java API / Re: Export model
« on: September 07, 2023, 09:39:11 AM »
Great thank you fixed again.

2
Python and Java API / Export model
« on: September 06, 2023, 08:19:03 AM »
Hello, I'm having trouble updating a script that worked with 1.6.1 and not 2.02 anymore.
Code: [Select]
def export_model():

    ### export model
    import Metashape
    doc = Metashape.app.document
    chunk = doc.chunk

    model_name = chunk.label
   
    print (chunk)
   
    save_model_folder = Metashape.app.getExistingDirectory("Please select folder to save model in")

    print (save_model_folder)

    model_save = Metashape.app.getString("Exported model name", model_name)

    chunk.exportModel(path = save_model_folder + "/" + "p" + model_save + "_.obj", format = "obj", texture_format = Metashape.ImageFormat.ImageFormatJPEG, save_texture=True)
 
    print ('export obj')

I get this error?
Error: Invalid argument value: format

any help appreciated

3
Python and Java API / Re: Image capture model view
« on: September 06, 2023, 02:00:01 AM »
Thank you Alexy that works perfectly!

4
Python and Java API / Image capture model view
« on: September 05, 2023, 02:45:58 AM »
Hello, I have an old script that works with 1.6.1 but need to update now.  What do I need to change to get the capture.modelView to work again?  I get this error Error: 'Metashape.Application' object has no attribute 'viewpoint' 
Here is my script.
Code: [Select]
def image_capture():

    ###export image capture to FSDBTesting/FaceSketches as a jpg
    import Metashape
    import shutil
    current_document = Metashape.app.document
    file_path = Path(Metashape.app.document.path)
    doc = Metashape.app.document
    chunk = doc.chunk
   
    for shape in chunk.shapes:
        if not shape.label:
            shape.label = shape.group.label
    viewpoint = Metashape.app.viewpoint
    cx = viewpoint.width
    cy = viewpoint.height
    cx = 1214
    cy = 912

    shape_name = chunk.label

    shape_name = shape_name[shape_name.find("_")+1:]

    save_shape_folder = "G:/Mining/Geology/Favona/FSDBTesting/FaceSketches"
    chunk_name = Metashape.app.getString("Enter location name?", shape_name)

    capture = Metashape.app.captureModelView( width = cx, height = cy, transparent = (False), hide_items = (False))
    #source = Metashape.DataSource.ModelData, mode = Metashape.ModelViewMode.ShadedModelView)
    print(capture.height)
    capture.save(save_shape_folder + "/" + chunk_name + ".jpg")

5
Python and Java API / vertices cannot be called when markers attached
« on: August 09, 2020, 10:46:42 PM »
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]))   

6
General / Re: Shape label properties V1.6.2
« on: April 29, 2020, 10:06:38 PM »
Thank you I'll wait for 1.6.3 before updating.

7
General / Shape label properties V1.6.2
« on: April 29, 2020, 05:53:41 AM »
In version 1.6.2 the behavior of the shape properties has changed.  After digitising a line the properties box automatically pops up and is labelled with a number incrementing from 1.  Is it possible to turn this off?

Thanks

8
Python and Java API / How to call project name and active chunk name
« on: April 19, 2020, 12:33:12 PM »
Hello,  I'm trying to export my model with the name of the active chunk and the current project as a concatenated name.  Is there a way to turn the names into a string? 
Code: [Select]
def check_string ():

    ###code for checking the convert obj to str function

    import Metashape
   
    doc = Metashape.app.document
    chunk = doc.chunk
    str(doc)
    print (doc)
    str(chunk)
    print (chunk)

9
Python and Java API / Re: exporting shape attributes
« on: April 19, 2020, 12:24:39 PM »
Thank you Alexey, shapes.vertices and shapes.attributes works great.  Though I couldn't get Metashape.shapes.FormatCSV to work with the exportShapes function.

10
Python and Java API / exporting shape attributes
« on: April 15, 2020, 08:48:52 AM »
Is there a way to script exporting of shape attributes to a .txt or .csv file?  Including the coordinates of the shape vertices?

11
Python and Java API / Re: Adding labels to shape groups
« on: November 12, 2019, 11:36:59 PM »
Thanks Alexey works great :D

12
Python and Java API / Re: Adding labels to shape groups
« on: November 11, 2019, 09:41:05 PM »
Hi Alexey,

Yes every shape in the group that gets drawn needs to have a label that is the same as the group name.  My script below creates the default shape groups.


   current_document = Metashape.app.document
   current_chunk = current_document.chunk
   
   default_shp_groups = {'QV Maj':[255,0,0], 'QV Min':[255,0,0], 'FAULT':[38,0,255],'AN':[0,170,0], 'CHL':[0,0,0], 'BM':[0,0,0], 'CL':[0,170,255], 'COR':[0,85,0], 'INE':[255,85,0], 'BND':[0,0,0], 'BX':[0,0,0], 'MAS':[0,0,0], 'OX':[255,85,0], 'pd':[0,0,0], 'stk':[255,0,0] }

   #loop new groups to add
   for new_shp_group_key in default_shp_groups:
   
      #set test if group to be added already exists to False
      new_shp_group_key_exists = False
   
      #loop existing groups
      for existing_shp_group in current_chunk.shapes.groups:
      
         #test if new group to be added already exists      
         if new_shp_group_key == existing_shp_group.label:
            new_shp_group_key_exists = True
   
      if new_shp_group_key_exists == False:   
         new_group = current_chunk.shapes.addGroup()
         new_group.label = new_shp_group_key
         new_group.color = (default_shp_groups[new_shp_group_key][0], default_shp_groups[new_shp_group_key][1], default_shp_groups[new_shp_group_key][2])


   

13
Python and Java API / Adding labels to shape groups
« on: November 10, 2019, 10:43:34 PM »
does anyone know how I might add labels to shape groups via a python script?  I have a script that creates a bunch of default shape groups, but I want the labels for everything in these shape groups to match the group name.

14
General / Re: moving shapes with referenced models
« on: August 18, 2019, 10:44:30 PM »
Thanks Alexey, works perfectly

15
General / moving shapes with referenced models
« on: August 16, 2019, 06:55:29 AM »
When referencing a model using markers and loading reference coordinates, any shapes created stay at the original model position prior to the transformation.  It is possible to have shapes move by the same transformation as the model?  My work flow requires that shapes are drawn on the model prior to obtaining the survey coordinates required to reference the model.

Pages: [1]