1

How to get the black line aligned with the boundaries of the rectangel

How can I cut of the parts of the black line inside the red rings such that the line is aligned with the boundaries of the green-blue rectangel?

The black line consists of 2 line segments with no fill that is joined together and the green-blue rectangel does not have any stroke.

I have tried to put a other rectangel object above the parts I want to remove together with the pathfinder tool withouth any success. I also used object -> path -> divide objects below. I have also tried the knife and the scissor. Finally I added a new anchor point on the intersection of the line path and the boundary of the green-blue rectangel, before I removed the old anchor point in the end of the black line without success.

1
  • 1
    Have you tried using a clipping mask?
    – AndrewH
    Commented May 24, 2019 at 13:01

1 Answer 1

1

As AndrewH says, a clipping mask is the easiest way to achieve this effect. A mask hides all elements outside of its boundary, but it can only be applied to single objects or groups.

  1. Group the two line segments together by selecting both of them (using the selection arrow, click on one, then Shift+click on the other) and choose Object > Group or press Ctrl / Cmd+G;
  2. Select your rectangle and use Edit > Copy (or Ctrl / Cmd + C) to put it on your pasteboard;
  3. Select Edit > Paste in Front or press Ctrl / Cmd + F to make an exact copy that is in the same place as the original;
  4. Arrange that new copy on top of the line group using either the Layers palette or Object > Arrange > Bring to Front or Shift+Ctrl / Cmd+];
  5. Remove the copy's fill so you can see what your are doing. The copy should now be a rectangle without any stroke or fill;
  6. With the no-stroke-no-fill rectangle still selected, use the selection arrow and Shift+click the group of line segments to add them to your current selection;
  7. Choose Object > Clipping Mask > Make or press Ctrl / Cmd+7.

The clipping mask is a kind of group, which you can still enter isolation mode for (Double click on any contents to enter) and then edit its contents or the actual clipping path. Expanding a clip group in the Layers palette makes its structure a bit clearer.

Just remember that when you create a mask. Illustrator will use the topmost object as the mask, and mask that what is below, provided that it's a single entity (object or group). You can use compound paths as masks, but not groups.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.