Git Product home page Git Product logo

Comments (4)

adam-urbanczyk avatar adam-urbanczyk commented on June 3, 2024

Are you looking for this: assy.constrain(..., "mybox_name?dummybox",...)? If so, take a look at the assy tutorial: constraints-definition.

from cadquery.

huskier avatar huskier commented on June 3, 2024

@adam-urbanczyk Thank you for your quick reply, Adam.

I've understood the materials you pointed, and I've tried "mybox?dummybox". The Python interpret gives the following error

KeyError: 'mybox?dummybox'

Actually, my object is to constrain 3D text with the help of BoundBox. My code is as following. At present, I use mybox1 to help me to make the dummy vertex. But it is not possible for further assembly. What I want is to use the tagged "dummybox".

import cadquery as cq
from cadquery.vis import show

text_string = "CadQuery"
font = "Arial"
size = 10
text3D = cq.Workplane("XZ").text(text_string, font=font, fontsize=size, distance=2)

xlen = text3D.val().BoundingBox().xlen
ylen = text3D.val().BoundingBox().ylen
zlen = text3D.val().BoundingBox().zlen

mybox = cq.Workplane().box(xlen, ylen, zlen, centered=True).tag("dummybox").faces("<Y").tag("boxY_Negtive").end().faces("<Z").tag("boxZ_Negtive").end(2) 
mybox1 = cq.Workplane().box(xlen, ylen, zlen, centered=True)

asm = cq.Assembly(name="TextOnPanel")
asm.add(text3D, color=cq.Color(1, 0, 0), name="text3D")
asm.add(mybox, color=cq.Color(0, 0, 1), name="mybox")

text3DCenter = text3D.val().BoundingBox().center
myboxCenter = mybox1.val().BoundingBox().center

(
    asm
    .constrain("text3D@faces@>Y", "mybox?boxY_Negtive", "Axis")
    .constrain("text3D@faces@>Z[-1]", "mybox?boxZ_Negtive", "Axis")    
    .constrain("text3D", cq.Vertex.makeVertex(text3DCenter.x, text3DCenter.y, text3DCenter.z), "mybox?dummybox", cq.Vertex.makeVertex(myboxCenter.x, myboxCenter.y, myboxCenter.z), "Point") 
    #replacing "mybox?dummybox" with "mybox" could make the code work. However, dummybox is what I want.
)
asm.solve()
show(asm)

from cadquery.

adam-urbanczyk avatar adam-urbanczyk commented on June 3, 2024

Did you mean:

(
    asm
    .constrain("text3D@faces@>Y", "mybox?boxY_Negtive", "Axis")
    .constrain("text3D@faces@>Z[-1]", "mybox?boxZ_Negtive", "Axis")    
    .constrain("text3D", "mybox?dummybox", "Point") 
)

from cadquery.

huskier avatar huskier commented on June 3, 2024

Simple, Beautiful! Yes, that's what I want. I'm so obsessed with the CQ's assembly system. Thank you, Adam. @adam-urbanczyk

from cadquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.