Skip to content

How to use Retopology #43

@GoudaCouda

Description

@GoudaCouda

am trying to use retopology with the Python Api but when I run the script it will run it but the output mesh is the exact same. I have tried using both the 3dsmax.exe and the batch exe both say script completed successfully but the mesh remains the same. When I use 3dsmax it will launch and say retopology completed 0s. It seems its just running but then instantly completing or something.

Example Code I am trying



import pymxs
from pathlib import Path

# --- Paths (Hardcoded for simplicity) ---
INPUT_OBJ_PATH = r"C:\Path\To\Your\Input\Model.obj" 
OUTPUT_OBJ_PATH = r"C:\Path\To\Your\Output\RetopoModel.obj"

# --- Core Script Execution ---

# Get the MAXScript runtime interface
rt = pymxs.runtime

# Convert paths to posix style for MaxScript compatibility
input_path_posix = Path(INPUT_OBJ_PATH).as_posix()
output_path_posix = Path(OUTPUT_OBJ_PATH).as_posix()

# --- Import ---
nodes_before = set(rt.objects)
rt.importFile(input_path_posix, rt.Name("noPrompt"), using=rt.ObjImp)
nodes_after = set(rt.objects)
new_nodes = list(nodes_after - nodes_before)

# Find the first suitable geometry node (simplified selection)
imported_node = None
for node in new_nodes:
    if rt.isKindOf(node.baseObject, rt.GeometryClass) and not rt.isKindOf(node, rt.TargetObject):
         # Basic check - might need refinement depending on OBJ structure
         imported_node = node
         break

# --- Apply Modifier ---
rt.select(imported_node) # Select the node
modifier_instance = rt.RetopologyComponent() # Create the modifier instance
rt.addModifier(imported_node, modifier_instance) # Add it to the selected node
retopo_comp = modifier_instance # Get a reference to the modifier component


# --- Compute ---
retopo_comp.ComputeRetopology() # Trigger the computation

# --- Export ---
rt.select(imported_node) # Ensure the node is selected
rt.exportFile(output_path_posix, rt.Name("noPrompt"), selectedOnly=True, using=rt.ObjExp)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions