Run a Command, a .scr or a .lisp from dynamo

Solved it: Using the doc.SendStringToExecute method.

Source: start lisp-Command immediately after sendstringtoexecute - Autodesk Community

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor

def load_and_start_lisp(LispFilePath,LispCommand):

    Lisp2Load="(load " + "\"" + LispFilePath.Replace("\\","\\\\") + "\"" + ") "
    adoc.SendStringToExecute(Lisp2Load,True,False,False)	
    if LispCommand != "":
        adoc.SendStringToExecute(LispCommand.Trim() + " ", True,False,False)
        
	return Lisp2Load
	
# Assign your output to the OUT variable.
OUT = load_and_start_lisp(IN[0],IN[1])
1 Like