Results 1 to 3 of 3

Thread: Trimming with MAPTRIM

  1. #1
    Member tuomo.jarvinen's Avatar
    Join Date
    2015-09
    Location
    Jyväskylä, Finland
    Posts
    49
    Login to Give a bone
    0

    Default Trimming with MAPTRIM

    Hi,

    I'm trying to trim lines and polylines inside circles.

    goal.PNG

    Following lisp works with few circles to trim, but with many it fails giving an error: "Trim boundary must contain exactly one object."

    Any ideas?

    Code:
    (defun c:1b1tr (/ sset a Ent )
    (setvar "cmdecho" 0)
    (setvar "CMDDIA" 0)
    (command "_.undo" "begin")
    
    (princ "\n Select objects for cutting edges")
    (setq sset (ssget))
    (setq a 0)
    
    (repeat (sslength sset)
    (setq Ent (ssname sset a))
    (command "maptrim" "s" Ent "n" "n" "i" "y" "y" "i" )
    (setq a (1+ a))
    )
    
    (command "_.undo" "end")
    (setvar "cmdecho" 1)
    (setvar "CMDDIA" 1)
    (princ)
    )
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Trimming with MAPTRIM

    Yes MAPTRIM failed in loop, i don't know why!
    But in your case, you can try this, seem to work.

    Code:
    (defun c:1b1tr ( / js dxf_cod lremov  mod_sel n ent pt rad pt1 pt2 js_trim ent_l dxf_ent dxf_10 dxf_11)
      (princ "\nSelect model object for cutting edges.")
      (while
        (null
          (setq js
            (ssget "_+.:E:S"
              (list
                '(0 . "CIRCLE")
                (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
                (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
              )
            )
          )
        )
        (princ "\nIsn't an available object!")
      )
      (setq dxf_cod (entget (ssname js 0)))
      (foreach m (foreach n dxf_cod (if (not (member (car n) '(0 67 410 8 6 62 48 420 70))) (setq lremov (cons (car n) lremov))))
        (setq dxf_cod (vl-remove (assoc m dxf_cod) dxf_cod))
      )
      (initget "Single All Manual")
      (if (eq (setq mod_sel (getkword "\nSelect mode, [Single/All/Manual]<Manual>: ")) "Single")
        (setq n -1)
        (if (eq mod_sel "All")
            (setq js (ssget "_X" dxf_cod) n -1)
            (setq js (ssget dxf_cod) n -1)
        )
      )
      (cond
        (js
          (if (eq mod_sel "All") (command "_.zoom" "_extent"))
          (repeat (setq n (sslength js))
            (setq
              ent (ssname js (setq n (1- n)))
              dxf_cod (entget ent)
              pt (cdr (assoc 10 dxf_cod))
              rad (cdr (assoc 40 dxf_cod))
              pt1 (mapcar '- pt (list rad rad 0.0))
              pt2 (mapcar '+ pt (list rad rad 0.0))
            )
            (cond
              ((and ent pt1 pt2)
                (setq js_trim
                  (ssget "_C" pt1 pt2
                    (list
                      '(0 . "LINE")
                      (cons 67 (if (eq (getvar "CVPORT") 1) 1 0))
                      (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model"))
                    )
                  )
                )
                (ssdel ent js_trim)
                (cond
                  ((and js_trim (not (zerop (sslength js_trim))))
                    (repeat (setq nb (sslength js_trim))
                      (setq
                        ent_l (ssname js_trim (setq nb (1- nb)))
                        dxf_ent (entget ent_l)
                        dxf_10 (cdr (assoc 10 dxf_ent))
                        dxf_11 (cdr (assoc 11 dxf_ent))
                      )
                      (cond
                        ((equal dxf_10 pt 1E-8)
                          (entmod (subst (cons 10 (polar dxf_10 (angle dxf_10 dxf_11) rad)) (assoc 10 dxf_ent) dxf_ent))
                        )
                        ((equal dxf_11 pt 1E-8)
                          (entmod (subst (cons 11 (polar dxf_11 (angle dxf_11 dxf_10) rad)) (assoc 11 dxf_ent) dxf_ent))
                        )
                      )
                    )
                  )
                )
              )
            )
          )
          (if (eq mod_sel "All") (command "_.zoom" "_previous"))
        )
      )
      (prin1)
    )

  3. #3
    Member tuomo.jarvinen's Avatar
    Join Date
    2015-09
    Location
    Jyväskylä, Finland
    Posts
    49
    Login to Give a bone
    0

    Default Re: Trimming with MAPTRIM

    Awesome, thank you!

    Maybe some sort of virtual memory issue with MAPTRIM.

Similar Threads

  1. Need help with trimming.
    By d.m.polsky in forum AutoLISP
    Replies: 8
    Last Post: 2009-11-20, 03:35 PM
  2. Trimming
    By Cadventurer in forum AutoCAD General
    Replies: 13
    Last Post: 2008-10-25, 10:48 AM
  3. Trimming
    By shg in forum AutoCAD General
    Replies: 5
    Last Post: 2008-03-04, 04:30 PM
  4. Improvement to Fillet & Chamfer trimming/no trimming options
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-07-12, 03:00 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •