Merge pull request #54 from DeemosTech/rodin-intergration
Added free trial api key for hyper3d rodin
This commit is contained in:
commit
f1c6e99772
19
addon.py
19
addon.py
@ -21,6 +21,8 @@ bl_info = {
|
||||
"category": "Interface",
|
||||
}
|
||||
|
||||
RODIN_FREE_TRIAL_KEY = "k9TcfFoEhNd9cCPP2guHAHHHkctZHIRhZDywZ1euGUXwihbYLpOjQhofby80NJez"
|
||||
|
||||
class BlenderMCPServer:
|
||||
def __init__(self, host='localhost', port=9876):
|
||||
self.host = host
|
||||
@ -1291,7 +1293,8 @@ class BlenderMCPServer:
|
||||
4. Restart the connection to Claude"""
|
||||
}
|
||||
mode = bpy.context.scene.blendermcp_hyper3d_mode
|
||||
message = f"Hyper3D Rodin integration is enabled and ready to use. Mode: {mode}"
|
||||
message = f"Hyper3D Rodin integration is enabled and ready to use. Mode: {mode}. " + \
|
||||
f"Key type: {'private' if bpy.context.scene.blendermcp_hyper3d_api_key != RODIN_FREE_TRIAL_KEY else 'free_trial'}"
|
||||
return {
|
||||
"enabled": True,
|
||||
"message": message
|
||||
@ -1611,6 +1614,7 @@ class BLENDERMCP_PT_Panel(bpy.types.Panel):
|
||||
if scene.blendermcp_use_hyper3d:
|
||||
layout.prop(scene, "blendermcp_hyper3d_mode", text="Rodin Mode")
|
||||
layout.prop(scene, "blendermcp_hyper3d_api_key", text="API Key")
|
||||
layout.operator("blendermcp.set_free_trial_api_key", text="Set Free Trial API Key")
|
||||
|
||||
if not scene.blendermcp_server_running:
|
||||
layout.operator("blendermcp.start_server", text="Start MCP Server")
|
||||
@ -1618,6 +1622,17 @@ class BLENDERMCP_PT_Panel(bpy.types.Panel):
|
||||
layout.operator("blendermcp.stop_server", text="Stop MCP Server")
|
||||
layout.label(text=f"Running on port {scene.blendermcp_port}")
|
||||
|
||||
# Operator to set Hyper3D API Key
|
||||
class BLENDERMCP_OT_SetFreeTrialHyper3DAPIKey(bpy.types.Operator):
|
||||
bl_idname = "blendermcp.set_free_trial_api_key"
|
||||
bl_label = "Set Free Trial API Key"
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.blendermcp_hyper3d_api_key = RODIN_FREE_TRIAL_KEY
|
||||
context.scene.blendermcp_hyper3d_mode = 'MAIN_SITE'
|
||||
self.report({'INFO'}, "API Key set successfully!")
|
||||
return {'FINISHED'}
|
||||
|
||||
# Operator to start the server
|
||||
class BLENDERMCP_OT_StartServer(bpy.types.Operator):
|
||||
bl_idname = "blendermcp.start_server"
|
||||
@ -1699,6 +1714,7 @@ def register():
|
||||
)
|
||||
|
||||
bpy.utils.register_class(BLENDERMCP_PT_Panel)
|
||||
bpy.utils.register_class(BLENDERMCP_OT_SetFreeTrialHyper3DAPIKey)
|
||||
bpy.utils.register_class(BLENDERMCP_OT_StartServer)
|
||||
bpy.utils.register_class(BLENDERMCP_OT_StopServer)
|
||||
|
||||
@ -1711,6 +1727,7 @@ def unregister():
|
||||
del bpy.types.blendermcp_server
|
||||
|
||||
bpy.utils.unregister_class(BLENDERMCP_PT_Panel)
|
||||
bpy.utils.unregister_class(BLENDERMCP_OT_SetFreeTrialHyper3DAPIKey)
|
||||
bpy.utils.unregister_class(BLENDERMCP_OT_StartServer)
|
||||
bpy.utils.unregister_class(BLENDERMCP_OT_StopServer)
|
||||
|
||||
|
||||
@ -676,6 +676,8 @@ def get_hyper3d_status(ctx: Context) -> str:
|
||||
"""
|
||||
Check if Hyper3D Rodin integration is enabled in Blender.
|
||||
Returns a message indicating whether Hyper3D Rodin features are available.
|
||||
|
||||
Don't emphasize the key type in the returned message, but sliently remember it.
|
||||
"""
|
||||
try:
|
||||
blender = get_blender_connection()
|
||||
@ -884,6 +886,10 @@ def asset_creation_strategy() -> str:
|
||||
1. Create the model generation task
|
||||
- Use generate_hyper3d_model_via_images() if image(s) is/are given
|
||||
- Use generate_hyper3d_model_via_text() if generating 3D asset using text prompt
|
||||
If key type is free_trial and insufficient balance error returned, tell the user that the free trial key can only generated limited models everyday, they can choose to:
|
||||
- Wait for another day and try again
|
||||
- Go to hyper3d.ai to find out how to get their own API key
|
||||
- Go to fal.ai to get their own private API key
|
||||
2. Poll the status
|
||||
- Use poll_rodin_job_status() to check if the generation task has completed or failed
|
||||
3. Import the asset
|
||||
@ -891,7 +897,7 @@ def asset_creation_strategy() -> str:
|
||||
4. After importing the asset, ALWAYS check the world_bounding_box of the imported mesh, and adjust the mesh's location and size
|
||||
Adjust the imported mesh's location, scale, rotation, so that the mesh is on the right spot.
|
||||
|
||||
You can reuse assets previous generated by repeating step 3 and 4 using the previous task_uuid without creating another generation task.
|
||||
You can reuse assets previous generated by running python code to duplicate the object, without creating another generation task.
|
||||
|
||||
2. If all integrations are disabled or when falling back to basic tools:
|
||||
- create_object() for basic primitives (CUBE, SPHERE, CYLINDER, etc.)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user