Skip to main content

PsimIsSubcircuit

Usage

psim.PsimIsSubcircuit();

Python Help

py.help(psim.PsimIsSubcircuit)

Python def

def PsimIsSubcircuit(self, schFilePath_or_Obj):
if not self.IsValid():
print("PSIM object was not loaded.")
return 0;

sch_closeFile = False
schHandle = 0
#is schFilePath a filePath or schematicID?
if isinstance(schFilePath_or_Obj, PSIM_schematic):
schHandle = schFilePath_or_Obj.value
elif isinstance(schFilePath_or_Obj, str):
schFilePath = schFilePath_or_Obj
SimOpenSchematicFileW = getattr(self.psimHandle, "SimOpenSchematicFileW")
if not SimOpenSchematicFileW:
raise AttributeError(self.VersionErrorMessage)

SimOpenSchematicFileW.restype = ctypes.c_int
# int SimOpenSchematicFileW(const wchar_t * szFileName, UINT nFlag)
schHandle = SimOpenSchematicFileW(ctypes.c_wchar_p(schFilePath), ctypes.c_int (1)); #returns 0 on error
if schHandle == 0 :
print("Unable to open schematic file " + schFilePath)
return 0;
sch_closeFile =True
elif schFilePath_or_Obj is None:
print("in PsimIsSubcircuit function, schFilePath_or_Obj is None")
else:
print("in PsimIsSubcircuit function, schFilePath_or_Obj is of an unknown type")

IsSub = getattr(self.psimHandle, "SimIsSubcircuit")
if not IsSub:
raise AttributeError(self.VersionErrorMessage)
res = IsSub(schHandle)

if sch_closeFile:
CloseSchematicFile = getattr(self.psimHandle, "SimCloseSchematicFile")
if not CloseSchematicFile:
raise AttributeError(self.VersionErrorMessage)

CloseSchematicFile.restype = ctypes.c_int
# int SimCloseSchematicFile(int nSchematicID)
CloseSchematicFile(schHandle); #returns 0 on error

return res