Skip to content

Commit

Permalink
Modify python imports to work with SDK package too (Even if lib3mf is…
Browse files Browse the repository at this point in the history
… not installed through PyPI, the examples would work as long as the SDK structure is maintained)
  • Loading branch information
vijaiaeroastro authored and gangatp committed May 15, 2024
1 parent 1316067 commit c7f7aa8
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
2 changes: 0 additions & 2 deletions SDK/Examples/Python/3mf_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: An example to convert between 3MF and STL
Interface version: 2.3.1
Expand Down
2 changes: 0 additions & 2 deletions SDK/Examples/Python/add_triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: Simplest 3mf example that just includes a single triangle
Interface version: 2.3.1
Expand Down
2 changes: 0 additions & 2 deletions SDK/Examples/Python/beam_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: Beam Lattice example
Interface version: 2.3.1
Expand Down
2 changes: 0 additions & 2 deletions SDK/Examples/Python/color_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: Color cube example
Interface version: 2.3.1
Expand Down
2 changes: 0 additions & 2 deletions SDK/Examples/Python/create_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: An example that creates multiple components using transformations
Interface version: 2.3.1
Expand Down
2 changes: 0 additions & 2 deletions SDK/Examples/Python/create_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: Create a simple cube
Interface version: 2.3.1
Expand Down
2 changes: 0 additions & 2 deletions SDK/Examples/Python/extract_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: Extract info from a 3MF model
Interface version: 2.3.1
Expand Down
22 changes: 17 additions & 5 deletions SDK/Examples/Python/lib3mf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,28 @@
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0-develop.
Abstract: Common set of functions that are used across all examples
Interface version: 2.3.1
'''

import lib3mf
from lib3mf import get_wrapper
import os
import sys

try:
import lib3mf
from lib3mf import get_wrapper
except ImportError:
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Bindings", "Python"))
import Lib3MF as lib3mf
import Lib3MF


def get_wrapper():
libpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "Bin")
wrapper = Lib3MF.Wrapper(os.path.join(libpath, "lib3mf"))
return wrapper


def create_vertex(_mesh, x, y, z):
Expand Down Expand Up @@ -63,7 +75,6 @@ def add_triangle(_mesh, p1, p2, p3):
return triangle



def get_version(wrapper):
major, minor, micro = wrapper.GetLibraryVersion()
print("Lib3MF version: {:d}.{:d}.{:d}".format(major, minor, micro), end="")
Expand Down Expand Up @@ -150,6 +161,7 @@ def create_beam(v0, v1, r0, r1, c0, c1):
beam.CapModes[1] = convert_beam_string_to_enum(c1)
return beam


def create_triangle_color(color_group, color_id1, color_id2, color_id3):
triangle_properties = lib3mf.TriangleProperties()
triangle_properties.ResourceID = color_group.GetResourceID()
Expand Down

0 comments on commit c7f7aa8

Please sign in to comment.