Forum

Author Topic: How to build multiple models for single chunk?  (Read 3242 times)

joacampb

  • Newbie
  • *
  • Posts: 12
    • View Profile
How to build multiple models for single chunk?
« on: October 06, 2020, 07:48:53 PM »
Hello,

I would like to create a High-res model, and then also create a Low-res model. but running the .buildModel() method twice, always overwrites the existing 3D model. When using

Code: [Select]
chunk.buildModel(face_count=Metashape.LowFaceCount)

How do you prevent overwriting any pre-existing 3D models in a chunk?


From the documentation :
Quote
New components can be created using corresponding addXXX methods (addSensor, addCamera, addCamera-Group, addMarker, addScalebar, addFrame). Removal of components is supported by a single remove method,which can accept lists of various component types.


So I would need to use '.addModel()' to add a second model to the chunk? Which would make sense, but how do I then build the second model into the new 'empty' reference created by .addModel()?

Also, is there a definition of the concept of 'frames' for Metashape Python somwhere? I am also trying to figure out if I have to create a new frame for the second model to reside in? -I found an explanation in the official manual so I get frames now.

Any guidance would be appreciated.



* I am using Metashape 1.6.2 and Windows 10.




« Last Edit: October 07, 2020, 11:18:10 PM by joacampb »

wojtek

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: How to build multiple models for single chunk?
« Reply #1 on: October 07, 2020, 09:21:27 AM »
Code: [Select]
chunk.model = None

Use this before your build mesh step.

joacampb

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How to build multiple models for single chunk?
« Reply #2 on: October 07, 2020, 04:39:53 PM »
Thanks for the response, afraid I get a NameError when trying that:

Code: [Select]
>>> doc.chunks[1].model
2020-10-07 09:35:49 <Model '290979 faces, 147674 vertices'>
>>> doc.chunks[1].model = none
2020-10-07 09:36:05 Traceback (most recent call last):
2020-10-07 09:36:05   File "<console>", line 1, in <module>
2020-10-07 09:36:05 NameError: name 'none' is not defined

Is this something that needs to happen before ANY model is created?
« Last Edit: October 07, 2020, 10:53:14 PM by joacampb »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15090
    • View Profile
Re: How to build multiple models for single chunk?
« Reply #3 on: October 08, 2020, 12:47:23 PM »
Hello joacampb,

The code in Python is case sensitive. So you should use None when making an assignment:
Code: [Select]
doc.chunks[1].model = None
Best regards,
Alexey Pasumansky,
Agisoft LLC

joacampb

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: How to build multiple models for single chunk?
« Reply #4 on: October 16, 2020, 05:31:49 AM »
Thank you for clarifying Alexey!

the additional code worked.