Jump to content
Ultimaker Community of 3D Printing Experts
  • Sign Up
SmithsOfUrth

[Plugin] Scaling cube from point down to Z=0

Recommended Posts

Posted · [Plugin] Scaling cube from point down to Z=0

Hey guys!

 

I'm working on a plugin (for Cura 3.6+) to enable manual supports, and one of the features I want to add is to show some kind of "preview" of what area the support is going to be taking.

Right now, I'm creating a cube and adding it to a X,Y position using this code:
 

active_camera = self._controller.getScene().getActiveCamera()
picking_pass = PickingPass(active_camera.getViewportWidth(), active_camera.getViewportHeight())
picking_pass.render()

picked_position = picking_pass.getPickedPosition(event.x, event.y)

After that, the script creates a cube kinda manually (I'm basing myself on the SupportEraser plugin) with a value entered by the user. Thus, the cube has the same width, height and depth.
What I want to do is to make it as big in the Z axis as necessary so that it touches the build plate , and the user can see what it'd look like once it's processed.

Is there a way to scale it enough?

 

Thanks!

Share this post


Link to post
Share on other sites
Posted · [Plugin] Scaling cube from point down to Z=0

There are two things you can do; You can either create longer squares with the MeshBuilder and move them down a bit (since they are places based on their center) or you can scale the model (check the setScale function of the SceneNode that contains the meshdata)

Share this post


Link to post
Share on other sites
Posted · [Plugin] Scaling cube from point down to Z=0

Thanks for answering, nallath.

I ended up doing this to create a cube that touches the buildplate:

s = size / 2
dtb = distance_to_buildplate
verts = [ # 6 faces with 4 corners each
  [-s, -dtb,  s], [-s,  s,  s], [ s,  s,  s], [ s, -dtb,  s], # a = x-yz
  [-s,  s, -s], [-s, -dtb, -s], [ s, -dtb, -s], [ s,  s, -s], # b = x+yz
  [ s, -dtb, -s], [-s, -dtb, -s], [-s, -dtb,  s], [ s, -dtb,  s], # c = xy-z
  [-s,  s, -s], [ s,  s, -s], [ s,  s,  s], [-s,  s,  s], # d = xy+z 
  [-s, -dtb,  s], [-s, -dtb, -s], [-s,  s, -s], [-s,  s,  s], # e = +xyz
  [ s, -dtb, -s], [ s, -dtb,  s], [ s,  s,  s], [ s,  s, -s] # f = -xyz
]

where "distance_to_buildplate" is the position in the Y axis of the cube when you click on the model, which is the same thing as the distance from the cube the ground.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Our picks

    • Talking additive | The 3D printing podcast
      Why should we be the only ones asking questions? Join us and ask Jabil all your questions on September 22nd 5pm CET
        • Like
      • 2 replies
    • Ultimaker masterclass: Optimizing your Ultimaker Cura workflow
      Save your seat for either broadcast on September 23.
      What will you learn?
      · Best practices for iterative print preparation and every lesson you should learn from each print
      · The right way to use per-object settings and when they are most useful
      · Easy-to-use resources for anyone who wants to develop their own printer definitions, plugins, or print profiles
      · How to optimize print profile settings and whether to “keep” or “discard” changes
      · When is the right time to export your drawing from CAD? (Based on Ultimaker Cura’s surprising power as 3D control software)
      · And a whole lot more tips and tricks!
       
      How can I join?
      This free masterclass will take place twice:
      1. 11am CEST (5pm SGT, 5am EDT)
      2. 5pm CEST (11am EDT, 8am PDT, 11pm SGT)
        • Like
      • 0 replies
    • Do you use 3D printing at work? Let us know
      It doesn't matter if you are using 1 Ultimaker or 10, there is inspiration in everything. We're looking for ...
      • 1 reply
×
×
  • Create New...