Hi all,
I want to cut muliple polygons like that:
- Making the polygons.
- Rotate them.
- Cutting them all to fill a surface of another polygon.
Is there any way to do step three in a simple macro?
thanks,
Nadav
Hi all,
I want to cut muliple polygons like that:
Is there any way to do step three in a simple macro?
thanks,
Nadav
Hi Nadav,
I’m not entirely sure what you meant with your question, but here’s a macro (also attached to my answer) that should do something similar:
# Number of polygons
n_poly = 5
# Spacing
spacing = 1.5
# Angle
angle = - 5.0
# Insert a Rectangular Volume for overlay
# Insert new object
INSERTOBJECT 1, 1
# Change new object to Rectangular Volume
SETNSCPROPERTY 1, 1, 0, 0, "NSC_RBLK"
# Change overlaid volume size and position
# (should be computed instead of hard-coded)
# Y1 Half Width
SETNSCPARAMETER 1, 1, 2, 0.8
# Y2 Half Width
SETNSCPARAMETER 1, 1, 5, 0.8
# Z Length
SETNSCPARAMETER 1, 1, 3, (n_poly + 1) * spacing
# Z Position
SETNSCPOSITION 1, 1, 3, - spacing / 2
# Change opacity
SETNSCPROPERTY 1, 1, 142, 0, 5
# Loop over the polygons
FOR idx, 1, n_poly, 1
# Insert new object
INSERTOBJECT 1, 2
# Change new object to Rectangular Volume
SETNSCPROPERTY 1, 2, 0, 0, "NSC_RBLK"
# Change Rectangular Volume position and angle
SETNSCPOSITION 1, 2, 3, spacing * (idx - 1)
SETNSCPOSITION 1, 2, 4, angle
# Hide object
SETNSCPROPERTY 1, 2, 141, 0, 1
# Insert new object to undo the rotation first
INSERTOBJECT 1, 3
# Reference new object to the polygon
SETNSCPROPERTY 1, 3, 2, 0, 2
# Undo the rotation
SETNSCPOSITION 1, 3, 4, - angle
# Insert new object to perform intersection with
# overlaid Rectangular Volume
INSERTOBJECT 1, 4
# Change to Boolean Native
SETNSCPROPERTY 1, 4, 0, 0, "NSC_NATB"
# Update Ref Object
SETNSCPROPERTY 1, 4, 2, 0, 3
# Undo axial translation
SETNSCPOSITION 1, 4, 3, - spacing * (idx - 1) - spacing / 2
# Edit object composition
# Object A = Overlaid Rectangular Volume
SETNSCPARAMETER 1, 4, 5, 1
# Object B = current Rectangular Volume
SETNSCPARAMETER 1, 4, 6, 2
# Edit boolean operation
SETNSCPROPERTY 1, 4, 1, 0, "A&B"
NEXT
It creates a large rectangular volume (hard-coded), and 5 default Rectangular Volumes. Then, it adds axial spacing between the default Rectangular Volumes, and rotates them by the same amount. After that, the macro adds Boolean Native objects which perform the interesction operation (&) of each default Rectangular Volume with the large rectangular volume (I colored the polygons manually for illustration purpose, I don’t think this can be done in ZPL ):
The trick is that the axial offset and rotation have to be undone to reposition the Boolean Object, since we first applied the axial shift and then the rotation, they should be undone in the opposite order. First, we have to undo the rotation, that is why the script adds a Null object that references the default Rectangular Volume and perform the opposite rotation. Then, the Boolean Native is referenced to the Null object and the axial shift is undone. This can be made a little simpler if you just tilt all 5 default Rectangular Volume, perform the boolean operation and then shift them axially, but since you asked with your steps in mind, this is my solution.
I hope this makes sense.
Take care,
David
Hi David,
Thansk a lot for the detailed answer.
Will it also work when some of the polygons at the edges are different in structure:
Sorry for the first explantion. My bad.
Thanks and best regards,
Nadav
Hi Nadav,
Yes, it should still work fine. The & operator in the Boolean Native takes the intersection between the two Rectangular Volumes. However, you should be mindful of the relative coordinates between the objects.
Depending what you ultimately want to do, there might be easier way around this problem.
Take care,
David
Ok. Thanks again
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.