Import sv module

Provides a system for patient-specific cardiovascular modeling and simulation.
POST REPLY
User avatar
Shion Matsumoto
Posts: 14
Joined: Tue Nov 06, 2018 9:09 am

Import sv module

Post by Shion Matsumoto » Mon Jul 06, 2020 1:11 pm

Hi,

I have been working with the sv Python module and was wondering if I could import the sv module much like I would import numpy or some other Python module. Currently

Code: Select all

from sv import *
only works if I run the script using

Code: Select all

sv --python -- script.py
, but I would like to be able to run the script in the same way as I would run any other Python script so that I can debug the scripts. Would something like this be possible or would you recommend another way to debug scripts?

Best,
Shion

User avatar
David Parker
Posts: 1674
Joined: Tue Aug 23, 2005 2:43 pm

Re: Import sv module

Post by David Parker » Tue Jul 07, 2020 2:41 pm

Hi Shion,

The SV Python API can only be used within the SV Python environment. Running sv --python puts you in the SV Python interpreter. You can then run and debug scripts interactively. For example (on a Mac)

Code: Select all

$ sv --python
SimVascular Python Shell
Copyright (c) Stanford University, The Regents of the University
              of California, and others.  All Rights Reserved.

Python 3.5.5 (default, Jun 30 2019, 23:56:41) 
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> import sv
New gRepository created from cv_solid_init
  Parasolid:   30.0.167
  TetGen:      1.5.1
PyModule_Create called
               splinePolygonContour Enabled
               levelSetContour Enabled
               polygonContour Enabled
               circleContour Enabled
               splinePolygonContour Enabled
  OpenCASCADE: 7.3.0
  Itk:         4.13.2
               TetGen Adaption Enabled
>>> 
>>> import vtk
>>> import numpy
>>> import os
>>> print(os.path.abspath(vtk.__file__))
/Applications/SimVascular.app/Contents/Resources/svExternals/lib/python3.5/site-packages/vtk/__init__.py
Cheers,
Dave

POST REPLY