Author Topic: Trim hatches with lisp: no fence, no crossing ... ??  (Read 1943 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 650
Trim hatches with lisp: no fence, no crossing ... ??
« on: December 11, 2017, 03:04:58 AM »
There are 2 similar questions, but no answers:
Trim hatch by layer / https://www.theswamp.org/index.php?topic=53379.msg580946#msg580946
How to trim hatch object? / https://www.theswamp.org/index.php?topic=39580.msg480057#msg480057

Situation:
- I have a simple "wall": some parallel lines, hatches between it
- I want to trim the wall between two lines
-> see attachment

Manual editing - Basic problem:
- In manual editing with mouse, the hatches don't accept a selection with "fence" or "crossing".
- If a selection set contains hatches (e.g. lines plus hatches), the entire selection set will be ignored.
- The selection of the hatches has to be done click by click.

Lisp coding:
- Same behaviour as described above
- When I start with a "select" command (ssget fence) I can select all objects.
- But when sending them to the trim-command ("command trim trimlines (ssname 1) (ssname 2)"), they don't have the right position to trim. They don't trim between the lines (where I defined the fence for selection), they trim between the beginning of the object and the first line.

Question:
- What to do?
- How to trim hatches between two lines (defined via 4 points)?

Have a fine day!
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

ahsattarian

  • Newt
  • Posts: 112
Re: Trim hatches with lisp: no fence, no crossing ... ??
« Reply #1 on: July 14, 2021, 03:22:41 AM »
This does the job  :


Code - Auto/Visual Lisp: [Select]
  1. (defun c:trimfence ()
  2.   (prompt "\n Select Edge for cutting : ")
  3.   (setq ss (ssget))
  4.   (setq po1 (getpoint "\n First Point : "))
  5.   (setvar "osmode" 0)
  6.   (setvar "autosnap" 39)
  7.   (setq po2 (getpoint "\n Second Point : " po1))
  8.   (command "trim" ss "")
  9.   (setq nu 100)
  10.   (setq kk -1)
  11.   (repeat (1+ nu)
  12.     (setq kk (1+ kk))
  13.     (setq po (polar po1 (angle po1 po2) (* (distance po1 po2) (/ (float kk) (float nu)))))
  14.     (command po)
  15.   )
  16.   (command)
  17.   (princ)
  18. )