Disabling command logging temporarily


From the curiosity drawer. This python snippet uses “v1.5 command” functionality from back in the day to disable command logging for a specific command invocation.

from siutils import si		# Application
from siutils import log		# LogMessage
from siutils import disp	# win32com.client.Dispatch
from siutils import C		# win32com.client.constants


sClassID = "{19085F81-CDD6-471C-9CA1-7C7F4F2A0166}"

# This command is logged
si.FindObjects( "", sClassID )

log( "--------------------------" )
# Get the command and disable logging
oCmd = si.Commands("Find Objects")
oCmd.SetFlag( C.siNoLogging, True )
 
# Not allowed to update existing commands with Update()
# so we have to manually set arguments and execute the command
oCmd.Arguments(0).Value = ""
oCmd.Arguments(1).Value = sClassID

oICETrees = oCmd.Execute();    # Execute - nothing logged
for t in oICETrees:
	log( t.FullName )
log( "--------------------------" )
 
# This still is logged, no need to reset flag because we never updated the command
si.FindObjects( "", sClassID )

The typical way to [temporarily] disable command logging is by setting the cmdlog preference:

Application.Preferences.SetPreferenceValue( "scripting.cmdlog", False )
Application.CreatePrim("Cone", "MeshSurface", "", "")

Softimage resets the pref automatically.

You could use a Python decorator to do this.