+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 23
  1. #11
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Great Syria , Lives in Abu Dhabi
    Posts
    3,946

    Default

    Registered forum members do not see this ad.

    irneb , that would disable the visibility of the selection set for all open drawings .

    e.g , try to move any entity in any opened drawing and you will find out that the high lighting objects would be disabled when you try to select any object.

    Regards.
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  2. #12
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    Yes, it's one of the painful aspects of only using portions of the Express tools. You could always allow for such things by saving the value of Highlight and the restoring it at the end of the function.

    I.e. something like this:
    Code:
    (defun c:MExTrim  (/ highlight *error* ss n en ed enA minpt maxpt dx dy pt dxx dyy)
      (vl-load-com)
      (setq highlight (getvar "HighLight"))
      (defun *error* (msg)
        (if highlight (setvar "HighLight" highlight))
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **")))
        (princ))
      (prompt "\nSelect closed entities: ")
      (if (setq ss (ssget (append (list '(-4 . "<or")        '(0 . "CIRCLE")      '(-4 . "<and")       '(0 . "*POLYLINE")
                                        '(70 . 1)            '(-4 . "and>")       '(-4 . "<and")       '(0 . "SPLINE")
                                        '(70 . 11)           '(-4 . "and>")       '(-4 . "<and")       '(0 . "ELLIPSE")
                                        '(41 . 0.0))
                                  (list (cons 42 (* 2 pi)))
                                  (list '(-4 . "and>") '(-4 . "or>")))))
        (progn (setq n (sslength ss))
               (while (>= (setq n (1- n)) 0)
                 (setq en  (ssname ss n)
                       ed  (entget en)
                       enA (vlax-ename->vla-object en))
                 (vla-getboundingbox enA 'minpoint 'maxpoint)
                 (setq minpt (vlax-safearray->list minpoint)
                       maxpt (vlax-safearray->list maxpoint))
                 (setq dx (- (car maxpt) (car minpt)))
                 (setq dy (- (cadr maxpt) (cadr minpt)))
                 (setq pt '(0.0 0.0 0.0))
                 (while (not (ptinsideent pt en))
                   (setq dxx (* dx (rnd)))
                   (setq dyy (* dy (rnd)))
                   (setq pt (list (+ (car minpt) dxx) (+ (cadr minpt) dyy) 0.0)))
                 (etrim en pt))))
      (*error* nil))
    Edit: Oh and BTW, thanks marko - that works great even on polylines!
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  3. #13
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electrical.
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Great Syria , Lives in Abu Dhabi
    Posts
    3,946

    Default

    Looks interesting indeed .

    sub-function ptinsideent is missing
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  4. #14
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    Quote Originally Posted by Tharwat View Post
    Looks interesting indeed .

    sub-function ptinsideent is missing
    Yes, that function is part of marko's code. I've taken marko's code and only shown the defun where I've modified it to include for the highlight reset.
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  5. #15
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Apr 2012
    Posts
    6

    Default

    This routine is resulting in everything outside of my circles being trimmed, leaving the portion of line inside as per #3 in ReMark's sketch above. Is there a setting that I could change for it to result in #2 in ReMark's sketch?

  6. #16
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    May 2012
    Posts
    4

    Default

    Hi,

    Really its very useful ...........

    thank you,

  7. #17
    Full Member
    Using
    Land Desktop 2009
    Join Date
    Sep 2011
    Posts
    55

    Default

    Hi Irneb,
    I'm not well versed in lisp where to put. Please give the full lisp.thanks

  8. #18
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,737

    Default

    Copy marko_ribar's code from post #10, then replace the last portion starting with
    Code:
    (defun c:MExTrim ...
    with my code from post #12. Save all into a LSP file (normal text file just with a LSP extension instead of TXT). Then load that file into ACad - several ways. Then after that any defun in that file with a name starting with C: becomes a new command with the rest of the name (in this case MExTrim).
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  9. #19
    Super Member marko_ribar's Avatar
    Computer Details
    marko_ribar's Computer Details
    Operating System:
    Windows 7 Ultimate X64
    Computer:
    Intel quad core CPU 4x2.66GHz, 8GB RAM
    Motherboard:
    INTEL compatibile
    CPU:
    quad core 4x2.66GHz
    RAM:
    8GB
    Graphics:
    NVIDIA GeForce 6600 GT
    Primary Storage:
    250 GB
    Secondary Storage:
    500 GB
    Monitor:
    Samsung 17''
    Discipline
    Architectural
    marko_ribar's Discipline Details
    Occupation
    Architecture, project designer, project visualisation
    Discipline
    Architectural
    Details
    space design - modeling and animations
    Using
    AutoCAD 2014
    Join Date
    Feb 2010
    Location
    Belgrade, Serbia, Europe
    Posts
    663

    Default

    I've modified my code according to BIGAL's discovery that on older Acad versions (etrim ent pt) won't work correctly without (acet-error-init) function and at the end followed by (acet-error-restore)... Look here for details...

    So here is complete code :
    Code:
    (defun c:MExTrim ( / rnd GroupByNum ptonline ptinsideent highlight 
                         ss n en ed enA minpt maxpt dx dy pt dxx dyy ) 
                         
      (vl-load-com)
    
      (load "extrim.lsp")
    
      (defun rnd (/ modulus multiplier increment rand)
        (if (not seed)
          (setq seed (getvar "DATE"))
        )
        (setq modulus    65536
              multiplier 25173
              increment  13849
              seed  (rem (+ (* multiplier seed) increment) modulus)
              rand     (/ seed modulus)
        )
      )
    
      (defun GroupByNum ( l n / f )
        (defun f ( a b )
          (if (and a (< 0 b))
            (cons (car a) (f (setq l (cdr a)) (1- b)))
          )
        )
        (if l (cons (f l n) (GroupByNum l n)))
      )
    
      (defun ptonline ( pt pt1 pt2 / vec12 vec1p d result )
        (setq vec12 (mapcar '- pt2 pt1))
        (setq vec12 (reverse (cdr (reverse vec12))))
        (setq vec1p (mapcar '- pt pt1))
        (setq vec1p (reverse (cdr (reverse vec1p))))
        (setq vec2p (mapcar '- pt2 pt))
        (setq vec2p (reverse (cdr (reverse vec2p))))
        (setq d (distance '(0.0 0.0) vec12) d1 (distance '(0.0 0.0) vec1p) d2 (distance '(0.0 0.0) vec2p))
        (if (equal d (+ d1 d2) 1e-8) (setq result T) (setq result nil))
        result
      )
    
      (defun ptinsideent ( pt ent / msp ptt xlin int k kk tst result )
        (vl-load-com)
        (setq msp (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
        (setq ptt (vlax-curve-getclosestpointto ent pt))
        (setq xlin (vla-addxline msp (vlax-3d-point pt) (vlax-3d-point ptt)))
        (setq int (GroupByNum (vlax-invoke (if (eq (type ent) 'ENAME) (vlax-ename->vla-object ent)) 'intersectwith xlin acExtendBoth) 3))
        (setq int (vl-sort int '(lambda (a b) (< (vlax-curve-getparamatpoint xlin a) (vlax-curve-getparamatpoint xlin b)))))
        (setq k 0)
        (while (< (setq k (1+ k)) (length int))
          (if (and (eq (rem k 2) 1) (ptonline pt (nth (- k 1) int) (nth k int))) (setq tst (cons T tst)) (setq tst (cons nil tst)))
        )
        (setq tst (reverse tst))
        (setq k 0)
        (mapcar '(lambda (x) (setq k (1+ k)) (if (eq x T) (setq kk k))) tst)
        (vla-delete xlin)
        (if kk
          (if (eq (rem kk 2) 1) (setq result T) (setq result nil))
          (setq result nil)
        )
        result
      )
    
      (setq highlight (getvar "HighLight"))
      (acet-error-init (list
                         (list   "cmdecho" 0
                               "highlight" highlight
                               "regenmode" 1
                                  "osmode" 0
                                 "ucsicon" 0
                              "offsetdist" 0
                                  "attreq" 0
                                "plinewid" 0
                               "plinetype" 1
                                "gridmode" 0
                                 "celtype" "CONTINUOUS"
                               "ucsfollow" 0
                                "limcheck" 0
                         )
                         T     ;flag. True means use undo for error clean up.
                         '(if redraw_it (redraw na 4))
                        );list
      );acet-error-init
    
      (prompt "\nSelect closed entities: ")
      (if (setq ss (ssget (append (list '(-4 . "<or") '(0 . "CIRCLE") '(-4 . "<and") '(0 . "*POLYLINE") '(-4 . "<not") '(-4 . "&=") '(70 . 8) '(-4 . "not>") '(-4 . "&=") '(70 . 1) '(-4 . "and>") '(-4 . "<and") '(0 . "SPLINE") '(-4 . "&=") '(70 . 1) '(-4 . "and>") '(-4 . "<and") '(0 . "ELLIPSE") '(41 . 0.0)) (list (cons 42 (* 2 pi))) (list '(-4 . "and>") '(-4 . "or>")))))
        (progn
          (setq n (sslength ss))
          (while (>= (setq n (1- n)) 0)
            (setq en (ssname ss n) ed (entget en) enA (vlax-ename->vla-object en))
              (vla-getboundingbox enA 'minpoint 'maxpoint)
            (setq
             minpt (vlax-safearray->list minpoint)
             maxpt (vlax-safearray->list maxpoint)
            )
            (setq dx (- (car maxpt) (car minpt)))
            (setq dy (- (cadr maxpt) (cadr minpt)))
            (setq pt '(0.0 0.0 0.0))
            (while (not (ptinsideent pt en))
              (setq dxx (* dx (rnd)))
              (setq dyy (* dy (rnd)))
              (setq pt (list (+ (car minpt) dxx) (+ (cadr minpt) dyy) 0.0))
            )
            (etrim en pt)
          )
        )
      )
      (acet-error-restore)
      (princ)
    )
    Regards, M.R.
    Last edited by marko_ribar; 31st Mar 2014 at 10:55 am.

    Marko Ribar, d.i.a. (graduated engineer of architecture)
    M.R. on YouTube

  10. #20
    Forum Newbie
    Using
    AutoCAD 2006
    Join Date
    Aug 2013
    Posts
    2

    Default

    Registered forum members do not see this ad.

    how to look like after it is run? Circle #3 (outside) ?

Similar Threads

  1. select objects inside circle
    By mauro in forum AutoCAD General
    Replies: 26
    Last Post: 28th Aug 2008, 06:04 pm
  2. Cannot Trim Circle between tangents
    By Bane in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 17
    Last Post: 7th Mar 2008, 02:13 am
  3. Trim inside circle
    By Cube3 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 12th Sep 2007, 07:26 am
  4. Text inside a circle
    By ebjco in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 22nd Nov 2005, 07:38 pm
  5. Text inside a circle
    By ebjco in forum AutoCAD Drawing Management & Output
    Replies: 7
    Last Post: 22nd Nov 2005, 04:27 pm

Tags for this Thread

Bookmarks

Posting Permissions

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