@@ -370,8 +370,6 @@ STEP can be loaded in all CAD tool, e.g. in FreeCAD and the XML be used in other
370
370
door.save(' door.step' )
371
371
door.save(' door.xml' )
372
372
373
- In the case of STEP colors are preserved but not transparency.
374
-
375
373
.. image :: _static/door_assy_freecad.png
376
374
377
375
@@ -389,9 +387,9 @@ Objects can be added to an assembly with initial locations supplied, such as:
389
387
assy = cq.Assembly()
390
388
assy.add(
391
389
cone,
392
- loc=cq.Location(cq.Vector (0, 0, 0), cq.Vector (1, 0, 0), 180),
390
+ loc=cq.Location((0, 0, 0), (1, 0, 0), 180),
393
391
name="cone0",
394
- color=cq.Color("green")
392
+ color=cq.Color("green"),
395
393
)
396
394
assy.add(cone, name="cone1", color=cq.Color("blue"))
397
395
@@ -733,21 +731,21 @@ Where:
733
731
734
732
import cadquery as cq
735
733
736
- b1 = cq.Workplane().box(1,1, 1)
734
+ b1 = cq.Workplane().box(1, 1, 1)
737
735
b2 = cq.Workplane().sphere(0.15)
738
736
739
737
assy = (
740
738
cq.Assembly()
741
- .add(b1,name='b1' )
742
- .add(b2, loc=cq.Location(cq.Vector (0,0, 4)), name='b2' , color=cq.Color(' red' ))
739
+ .add(b1, name="b1" )
740
+ .add(b2, loc=cq.Location((0, 0, 4)), name="b2" , color=cq.Color(" red" ))
743
741
)
744
742
745
743
# fix the position of b1
746
- assy.constrain('b1',' Fixed' )
744
+ assy.constrain("b1", " Fixed" )
747
745
# b2 on one of the edges of b1
748
- assy.constrain('b2',' b1@edges@>>Z and >>Y',' PointOnLine' )
746
+ assy.constrain("b2", " b1@edges@>>Z and >>Y", " PointOnLine" )
749
747
# b2 on another of the edges of b1
750
- assy.constrain('b2',' b1@edges@>>Z and >>X',' PointOnLine' )
748
+ assy.constrain("b2", " b1@edges@>>Z and >>X", " PointOnLine" )
751
749
# effectively b2 will be constrained to be on the intersection of the two edges
752
750
753
751
assy.solve()
@@ -768,31 +766,31 @@ The cost function is:
768
766
Where:
769
767
770
768
- :math: `\vec { c }` is the center of the argument,
771
- - :math: `param` is the parameter of the constraint - tuple specifying the target position,
772
- - :math: `\operatorname {dist}( \vec { a }, b)` is the distance between point :math: `\vec { a }` and
773
- line :math: `b`.
769
+ - :math: `param` is the parameter of the constraint - tuple specifying the target position.
774
770
775
771
776
772
.. cadquery ::
777
773
778
774
import cadquery as cq
779
775
780
- b1 = cq.Workplane().box(1,1, 1)
776
+ b1 = cq.Workplane().box(1, 1, 1)
781
777
b2 = cq.Workplane().sphere(0.15)
782
778
783
779
assy = (
784
780
cq.Assembly()
785
- .add(b1,name='b1')
786
- .add(b2, loc=cq.Location(cq.Vector(0,0,4)), name='b2', color=cq.Color('red'))
781
+ .add(b1, name="b1")
782
+ .add(b2, loc=cq.Location((0, 0, 4)), name="b2", color=cq.Color("red"))
783
+ .add(b1, loc=cq.Location((-2, 0, 0)), name="b3", color=cq.Color("red"))
787
784
)
788
785
786
+ pnt = (0.5, 0.5, 0.5)
787
+
789
788
# fix the position of b1
790
- assy.constrain('b1','Fixed')
791
- # b2 on one of the edges of b1
792
- assy.constrain('b2','b1@edges@>>Z and >>Y','PointOnLine')
793
- # b2 on another of the edges of b1
794
- assy.constrain('b2','b1@edges@>>Z and >>X','PointOnLine')
795
- # effectively b2 will be constrained to be on the intersection of the two edges
789
+ assy.constrain("b1", "Fixed")
790
+ # fix b2 center at point
791
+ assy.constrain("b2", "FixedPoint", pnt)
792
+ # fix b3 vertex position at point
793
+ assy.constrain("b3@vertices@<X and <Y and <Z", "FixedPoint", pnt)
796
794
797
795
assy.solve()
798
796
show_object(assy)
@@ -801,7 +799,7 @@ Where:
801
799
FixedRotation
802
800
=============
803
801
804
- FixedRotation fixes the rotation of the given argument to be equal to the value specified via the parameter of the constraint. The argument is rotated about it's origin firstly by the Z angle, then Y and finally X.
802
+ FixedRotation fixes the rotation of the given argument to be equal to the value specified via the parameter of the constraint.
805
803
806
804
This constraint locks all rotational degrees of freedom of the argument.
807
805
The cost function is:
@@ -821,21 +819,21 @@ Where:
821
819
822
820
import cadquery as cq
823
821
824
- b1 = cq.Workplane().box(1,1, 1)
825
- b2 = cq.Workplane().rect(0.1, 0.1).extrude(1,taper=-15)
822
+ b1 = cq.Workplane().box(1, 1, 1)
823
+ b2 = cq.Workplane().rect(0.1, 0.1).extrude(1, taper=-15)
826
824
827
825
assy = (
828
826
cq.Assembly()
829
- .add(b1,name='b1' )
830
- .add(b2, loc=cq.Location(cq.Vector (0,0, 4)), name='b2' , color=cq.Color(' red' ))
827
+ .add(b1, name="b1" )
828
+ .add(b2, loc=cq.Location((0, 0, 4)), name="b2" , color=cq.Color(" red" ))
831
829
)
832
830
833
831
# fix the position of b1
834
- assy.constrain('b1',' Fixed' )
832
+ assy.constrain("b1", " Fixed" )
835
833
# fix b2 bottom face position (but not rotation)
836
- assy.constrain(' b2@faces@<Z',' FixedPoint', (0,0, 0.5))
834
+ assy.constrain(" b2@faces@<Z", " FixedPoint", (0, 0, 0.5))
837
835
# fix b2 rotational degrees of freedom too
838
- assy.constrain('b2',' FixedRotation', (45,0, 45))
836
+ assy.constrain("b2", " FixedRotation", (45, 0, 45))
839
837
840
838
assy.solve()
841
839
show_object(assy)
@@ -862,21 +860,21 @@ Where:
862
860
863
861
import cadquery as cq
864
862
865
- b1 = cq.Workplane().box(1,1, 1)
866
- b2 = cq.Workplane().rect(0.1, 0.1).extrude(1,taper=-15)
863
+ b1 = cq.Workplane().box(1, 1, 1)
864
+ b2 = cq.Workplane().rect(0.1, 0.1).extrude(1, taper=-15)
867
865
868
866
assy = (
869
867
cq.Assembly()
870
- .add(b1,name='b1' )
871
- .add(b2, loc=cq.Location(cq.Vector (0,0, 4)), name='b2' , color=cq.Color(' red' ))
868
+ .add(b1, name="b1" )
869
+ .add(b2, loc=cq.Location((0, 0, 4)), name="b2" , color=cq.Color(" red" ))
872
870
)
873
871
874
872
# fix the position of b1
875
- assy.constrain('b1',' Fixed' )
873
+ assy.constrain("b1", " Fixed" )
876
874
# fix b2 bottom face position (but not rotation)
877
- assy.constrain(' b2@faces@<Z',' FixedPoint', (0,0, 0.5))
875
+ assy.constrain(" b2@faces@<Z", " FixedPoint", (0, 0, 0.5))
878
876
# fix b2 some rotational degrees of freedom too
879
- assy.constrain(' b2@faces@>Z',' FixedAxis', (1,0, 2))
877
+ assy.constrain(" b2@faces@>Z", " FixedAxis", (1, 0, 2))
880
878
881
879
assy.solve()
882
880
show_object(assy)
0 commit comments