vPython 3D Printing?

60 Views Asked by At

I have my school final year work that shows that you can use Python for 3D printing and I'm using vPython and I created some basic model of snowflake out of some boxes and rotating them but now I'm concerned of converting it into like STL file for 3D printing. I tried everything but unfortunately still without outcome.

I've tried different variations of libraries that can export it into stl but still nothing works. ChatGPT gives me some answers but nothing works and even more errors comes out.

I know that the snowflake isn't perfect but I just made some basic object to try to export it into 3D printable object how it would look and then I would work on some harder and cooler objects.

    from vpython import * 
    from time import *
    import math
    import  numpy as np
    from stl import mesh




    #Snowflake - sf
    stripLenght=5
    stripWidth=0.2
    stripDepth=0.2


    #box_obj.rotate(angle=radians(45), axis=vector(0, 1, 0), origin=vector(0, 0, 0))




    sf_strip_horiz=box(color=color.cyan,size=vector(stripLenght,stripWidth,stripDepth))

    sf_strip_vertical=box(color=color.cyan,size=vector(stripWidth,stripLenght,stripDepth))

    sf_strip_rotate1=box(color=color.cyan,size=vector(stripWidth,stripLenght,stripDepth))
    sf_strip_rotate1.rotate(angle=radians(45), axis=vector(0,0,1),origin=vector(0,0,0))

    sf_strip_rotate2=box(color=color.cyan,size=vector(stripWidth,stripLenght,stripDepth))
    sf_strip_rotate2.rotate(angle=radians(-45), axis=vector(0,0,1),origin=vector(0,0,0))

    #End of snowflake base
    #Start of mini end of flake


    #The angle parameter specifies the angle of rotation in radians.
    #The axis parameter specifies the axis of rotation as a vector.
    #The origin parameter specifies the point around which the rotation occurs

    #Upper two 
    ministrip1=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(-.3,2,0))
    ministrip1.rotate(angle=radians(-50), axis=vector(0,0,1),origin=vector(-.3,2,0))

    ministrip2=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(.3,2,0))
    ministrip2.rotate(angle=radians(50), axis=vector(0,0,1),origin=vector(.3,2,0))

    #Lower two
    ministrip3=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(-.3,-2,0))
    ministrip3.rotate(angle=radians(230), axis=vector(0,0,1),origin=vector(-.3,-2,0))

    ministrip4=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(.3,-2,0))
    ministrip4.rotate(angle=radians(-230), axis=vector(0,0,1),origin=vector(.3,-2,0))

    #Left strip
    #Lower
    ministrip5=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(-2,-.4,0))
    ministrip5.rotate(angle=radians(230), axis=vector(0,0,1),origin=vector(-2,-.4,0))
    #Upper
    ministrip6=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(-2,.4,0))
    ministrip6.rotate(angle=radians(-230), axis=vector(0,0,1),origin=vector(-2,.4,0))

    #Right strip
    #Lower
    ministrip7=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(2,-.4,0))
    ministrip7.rotate(angle=radians(-50), axis=vector(0,0,1),origin=vector(2,-.4,0))
    #Upper
    ministrip8=box(color=color.cyan,size=vector(1,0.2,0.2),pos=vector(2,.4,0))
    ministrip8.rotate(angle=radians(50), axis=vector(0,0,1),origin=vector(2,.4,0))

    #45 degree   upper left/right
    #Left
    ministrip9=box(color=color.cyan,size=vector(.8,0.2,0.2),pos=vector(-1.67,1.25,0))

    ministrip10=box(color=color.cyan,size=vector(.8,0.2,0.2),pos=vector(-1.35,1.7,0))
    ministrip10.rotate(angle=radians(-85), axis=vector(0,0,1),origin=vector(-1.35,1.7,0))

    #Right
    ministrip11=box(color=color.cyan,size=vector(.8,0.2,0.2),pos=vector(1.67,1.25,0))

    ministrip12=box(color=color.cyan,size=vector(.8,0.2,0.2),pos=vector(1.35,1.7,0))
    ministrip12.rotate(angle=radians(-85), axis=vector(0,0,1),origin=vector(1.35,1.7,0))

    #45degree  down left/right
    #Left
    ministrip13=box(color=color.cyan,size=vector(.8,0.2,0.2),pos=vector(-1.67,-1.3,0))

    ministrip14=box(color=color.cyan,size=vector(.8,0.2,0.2),    pos=vector(-1.25,-1.65,0))
    ministrip14.rotate(angle=radians(-85), axis=vector(0,0,1),origin=vector(-1.25,-1.65,0))

    #Right
    inistrip15=box(color=color.cyan,size=vector(.8,0.2,0.2),      pos=vector(1.67,-1.3,0))

    ministrip16=box(color=color.cyan,size=vector(.8,0.2,0.2),     pos=vector(1.25,-1.65,0))
    ministrip16.rotate(angle=radians(-85), axis=vector(0,0,1), origin=vector(1.25,-1.65,0))

    while True: 
      pass
0

There are 0 best solutions below