ynput / OpenPype

OpenPype has been surpassed by AYON and is now read only.
https://ayon.ynput.io
MIT License
286 stars 129 forks source link

Enhancement: Prioritize correct pymxs implementation over rt.execute for improved safety and efficiency in 3ds Max #4982

Closed Sponge96 closed 10 months ago

Sponge96 commented 1 year ago

Is there an existing issue for this?

Please describe the feature you have in mind and explain what the current shortcomings are?

Consider refactoring the existing implementation of 3dsmax to replace rt.execute() calls with the appropriate pymxs implementation. Although rt.execute()allows executing MAXScript code within pymxs, it is less efficient and less safe compared to using pymxs functions directly.rt.execute() involves parsing and evaluating MAXScript code, leading to a slight performance overhead. Additionally, and more importantly, it often bypasses crucial built-in safety mechanisms provided by the pymxs API, such as error handling. This can lead to silent fails making debugging more challenging.

How would you imagine the implementation of the feature?

Refactoring the code would involve replacing rt.execute() calls with there pymxs implementation (where possible). An example of this:

Current: frange_cmd = f"animationRange = interval {frame_start} {frame_end}" rt.execute(frange_cmd)

Refactor: rt.animationRange = rt.interval(frame_start, frame_end)

This new implementation directly assigns the desired animation range to rt.animationRange using the rt.interval() constructor. By doing so, we eliminate the need to construct a MAXScript command string and execute it using rt.execute(). This refactor improves efficiency and eliminates potential safety concerns associated with using rt.execute() for this particular example.

Are there any labels you wish to add?

Describe alternatives you've considered:

No response

Additional context:

No response

[cuID:OP-5945]

antirotor commented 10 months ago

Closing this as it is addressed by PRs mentioned above. If it is still issue, please re-open.