Lee Mac Posted April 2, 2010 Share Posted April 2, 2010 Bear in mind that mine only erases inside the pline Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 Again, I 'm so thankful and wish the best things in your life (Mr Lee,Ipseifert,alanjt). Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 Also Mr ReMark. Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 I had my WP and CP screwed up... (defun c:EIO (/ _p2ss o ent ssIn ssOut) ;; Erase Inside/Outside of selected LWPolyline ;; Alan J. Thompson, 04.02.10 (vl-load-com) (or *EIO:Opt* (setq *EIO:Opt* "Inside")) (setq _p2ss (lambda (ename meth) (ssget meth ((lambda (e / l) (foreach x e (and (eq 10 (car x)) (setq l (cons (cdr x) l)))) (reverse l) ) ;_ lambda (entget ename) ) ) ;_ ssget ) ;_ lambda ) ;_ setq (and (setq o (car (entsel "\nSelect LWPolyline: "))) (or (eq "LWPOLYLINE" (cdr (assoc 0 (setq ent (entget o))))) (alert "Invalid object!") ) ;_ or (not (initget 0 "Inside Outside")) (setq *EIO:Opt* (cond ((getkword (strcat "\nSpecify erase option [inside/Outside] <" *EIO:Opt* ">: "))) (*EIO:Opt*) ) ;_ cond ) ;_ setq (cond ((and (eq *EIO:Opt* "Inside") (setq ssIn (_p2ss o "_WP"))) ((lambda (i) (while (setq e (ssname ssIn (setq i (1+ i)))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ while ) ;_ lambda -1 ) ) ((eq *EIO:Opt* "Outside") (setq ssIn (_p2ss o "_CP") ssOut (ssget "_X" (list (cons 410 (getvar 'ctab)))) ) ;_ setq ((lambda (i) (while (setq e (ssname ssOut (setq i (1+ i)))) (if ssIn (or (ssmemb e ssIn) (eq o e) (vl-catch-all-apply (function entdel) (list e))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ if ) ;_ while ) ;_ lambda -1 ) ) ) ;_ cond ) ;_ and (princ) ) ;_ defun Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 Curious and playing around... (defun c:EIO (/ *error* _p2ss _ext _Pnt o ent u ssIn ssOut) ;; Erase Inside/Outside of selected LWPolyline ;; If Express Tools' EXTrim is found/loaded, crossing object(s) will be trimmed ;; Alan J. Thompson, 04.02.10 (vl-load-com) (or *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))) (or *EIO:Opt* (setq *EIO:Opt* "Inside")) (setq *error* (lambda (m) (and *AcadDoc* u (vla-endundomark *AcadDoc*)) (princ (strcat "\n" m)))) (setq _p2ss (lambda (ename meth) (ssget meth ((lambda (e / l) (foreach x e (and (eq 10 (car x)) (setq l (cons (cdr x) l)))) (reverse l) ) ;_ lambda (entget ename) ) ) ;_ ssget ) ;_ lambda _ext (lambda (e p) (and (load "extrim.lsp" nil) etrim (not (etrim o p)) ) ;_ and ) ;_ lambda _Pnt (lambda (e s / e o l p) (setq e (vlax-ename->vla-object e)) (setq p (vlax-curve-getendpoint (caar (vl-sort (cons (cons e (vla-get-area e)) (setq l (mapcar (function (lambda (# / o) (if (setq o (car (vlax-safearray->list (vlax-variant-value (vla-offset e (* # 0.000001))) ) ;_ vlax-safearray->list ) ;_ car ) ;_ setq (cons o (vla-get-area o)) ) ;_ if ) ;_ lambda ) ;_ function '(-1. 1.) ) ;_ mapcar ) ;_ setq ) ;_ cons (function (lambda (a b) (s (cdr a) (cdr b)))) ) ;_ vl-sort ) ;_ caar ) ;_ vlax-curve-getendpoint ) ;_ setq (mapcar (function (lambda (x) (vl-catch-all-apply (function vla-delete) (list (car x))))) l ) ;_ mapcar p ) ;_ lambda ) ;_ setq (and (setq o (car (entsel "\nSelect LWPolyline: "))) (or (eq "LWPOLYLINE" (cdr (assoc 0 (setq ent (entget o))))) (alert "Invalid object!") ) ;_ or (not (initget 0 "Inside Outside")) (setq *EIO:Opt* (cond ((getkword (strcat "\nSpecify erase option [inside/Outside] <" *EIO:Opt* ">: "))) (*EIO:Opt*) ) ;_ cond ) ;_ setq (setq u (not (vla-startundomark *AcadDoc*))) (cond ((and (eq *EIO:Opt* "Inside") (setq ssIn (_p2ss o "_WP"))) (_ext o (_pnt o <)) ((lambda (i) (while (setq e (ssname ssIn (setq i (1+ i)))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ while ) ;_ lambda -1 ) ) ((eq *EIO:Opt* "Outside") (_ext o (_pnt o >)) (setq ssIn (_p2ss o "_CP") ssOut (ssget "_X" (list (cons 410 (getvar 'ctab)))) ) ;_ setq ((lambda (i) (while (setq e (ssname ssOut (setq i (1+ i)))) (if ssIn (or (ssmemb e ssIn) (eq o e) (vl-catch-all-apply (function entdel) (list e))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ if ) ;_ while ) ;_ lambda -1 ) ) ) ;_ cond ) ;_ and (and *AcadDoc* u (vla-endundomark *AcadDoc*)) (princ) ) ;_ defun Will only trim if Express Tools' EXTrim exists. Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 Curious and playing around... Will only trim if Express Tools' EXTrim exists. thank you so much alan. i 've tested it. this error is desplayed: Command: EIO Select LWPolyline: Specify erase option [inside/Outside] : o bad argument type: VLA-OBJECT nil Command: Command: EIO Select LWPolyline: Specify erase option [inside/Outside] : i bad argument type: VLA-OBJECT nil Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 thank you so much alan.i 've tested it. this error is desplayed: Command: EIO Select LWPolyline: Specify erase option [inside/Outside] : o bad argument type: VLA-OBJECT nil Command: Command: EIO Select LWPolyline: Specify erase option [inside/Outside] : i bad argument type: VLA-OBJECT nil Man, you're having nothing but problems. It works totally fine for me. Hell, it will even prompt you if the selected PLine is on a locked layer. Post a drawing of exactly what you are trying this on. Just out of curiosity, paste the following in your command line and tell me what happens. (vl-load-com) (vla-get-layer (vlax-ename->vla-object (car (entsel)))) Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 (edited) (defun c:EXTEO (/ _p2ss o ent ssIn ssOut) (extrim) (vl-load-com) (or *EIO:Opt* (setq *EIO:Opt* "Inside")) (setq _p2ss (lambda (ename meth) (ssget meth ((lambda (e / l) (foreach x e (and (eq 10 (car x)) (setq l (cons (cdr x) l)))) (reverse l) ) ;_ lambda (entget ename) ) ) ;_ ssget ) ;_ lambda ) ;_ setq (or (eq "LWPOLYLINE" (cdr (assoc 0 (setq ent (entget o))))) (alert "Invalid object!") ) ;_ or (not (initget 0 "Inside Outside")) (setq ssIn (_p2ss o "_CP") ssOut (ssget "_X" (list (cons 410 (getvar 'ctab)))) ) ;_ setq ((lambda (i) (while (setq e (ssname ssOut (setq i (1+ i)))) (if ssIn (or (ssmemb e ssIn) (eq o e) (vl-catch-all-apply (function entdel) (list e))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ if ) ;_ while ) ;_ lambda -1 ) (princ) ) ;_ defun EXTEO I 've edited that code you posted in post NO.24 It is modified for trim and erase all objects outside of a polyline. I 've tested it. it works propely for me. It works just for autocad which has express tools installed. i have some problem with the functions for inside operation. Edited April 5, 2013 by SLW210 Add Code Tags Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 (vl-load-com) (vla-get-layer (vlax-ename->vla-object (car (entsel)))) I did. This is response: Command: (vl-load-com) Command: (vla-get-layer (vlax-ename->vla-object (car (entsel)))) Select object: "0" Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 (edited) (defun c:EXTEO (/ _p2ss o ent ssIn ssOut) (extrim) (vl-load-com) (or *EIO:Opt* (setq *EIO:Opt* "Inside")) (setq _p2ss (lambda (ename meth) (ssget meth ((lambda (e / l) (foreach x e (and (eq 10 (car x)) (setq l (cons (cdr x) l)))) (reverse l) ) ;_ lambda (entget ename) ) ) ;_ ssget ) ;_ lambda ) ;_ setq (or (eq "LWPOLYLINE" (cdr (assoc 0 (setq ent (entget o))))) (alert "Invalid object!") ) ;_ or (not (initget 0 "Inside Outside")) (setq ssIn (_p2ss o "_CP") ssOut (ssget "_X" (list (cons 410 (getvar 'ctab)))) ) ;_ setq ((lambda (i) (while (setq e (ssname ssOut (setq i (1+ i)))) (if ssIn (or (ssmemb e ssIn) (eq o e) (vl-catch-all-apply (function entdel) (list e))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ if ) ;_ while ) ;_ lambda -1 ) (princ) ) ;_ defun EXTEO I 've edited that code you posted in post NO.24 It is modified for trim and erase all objects outside of a polyline. I 've tested it. it works propely for me. It works just for autocad which has express tools installed. i have some problem with the functions for inside operation. Whatever floats your boat. However, what you've posted will not work. (extrim) is not a function (you would have to do it with (c:extrim) or (etrim ename point) ) and you don't have a prompt for the user to select an object to trim within. Edited April 5, 2013 by SLW210 Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 (vl-load-com) (vla-get-layer (vlax-ename->vla-object (car (entsel)))) I did. This is response: Command: (vl-load-com) Command: (vla-get-layer (vlax-ename->vla-object (car (entsel)))) Select object: "0" I just wanted to make sure your VLA functions were working properly. Post an example drawing or I can help you no more. Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 I just wanted to make sure your VLA functions were working properly.Post an example drawing or I can help you no more. I 've tested the code i modified on drawing attached in autocad 2008. example.dwg 12.lsp Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 you right man. i've ran extrim from aotucad command line before. that 's the reason my code was working with my drawing. Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 Dear Alan. I'm so so so and so thankful of your trying for solving my problem. I'm new in lisp programming. i'll just try to complete my knowledge by using your experience and other's. Therefore, i too apologise if my questions wast you and other 's time. Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 How is this one? I'll look at this later (dinner time, etc.). However, you should know: ;;; EXTRIM.LSP ;;; Copyright © 1999 by Autodesk, Inc. ;;; ;;; Your use of this software is governed by the terms and conditions of the ;;; License Agreement you accepted prior to installation of this software. ;;; Please note that pursuant to the License Agreement for this software, ;;; "[c]opying of this computer program or its documentation except as ;;; permitted by this License is copyright infringement under the laws of ;;; your country. If you copy this computer program without permission of ;;; Autodesk, you are violating the law." BTW, copyright information was placed there for a reason. People tend to get a little pissed off when one removes it. Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 Dear Alan.I'm so so so and so thankful of your trying for solving my problem. I'm new in lisp programming. i'll just try to complete my knowledge by using your experience and other's. Therefore, i too apologise if my questions wast you and other 's time. I wouldn't help if I didn't want to. Once I opened a new drawing, I encountered the vla-object nil error. I'll be back on later and give it a look (I'll end up using this myself, so I'd like it to work). Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 I 'm so glad for acquaintance with this forum. cause there are many peoples like you in this forum who have the purpose of helping others like me. Quote Link to comment Share on other sites More sharing options...
alanjt Posted April 2, 2010 Share Posted April 2, 2010 While eating, I thought of what the problem might be and I was correct... (defun c:EIO (/ *error* _p2ss _ext _Pnt o ent u ssIn ssOut) ;; Erase Inside/Outside of selected LWPolyline ;; If Express Tools' EXTrim is found/loaded, crossing object(s) will be trimmed ;; Alan J. Thompson, 04.02.10 (vl-load-com) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) (or *EIO:Opt* (setq *EIO:Opt* "Inside")) (setq *error* (lambda (m) (and *AcadDoc* u (vla-endundomark *AcadDoc*)) (princ (strcat "\n" m)))) (setq _p2ss (lambda (ename meth) (ssget meth ((lambda (e / l) (foreach x e (and (eq 10 (car x)) (setq l (cons (cdr x) l)))) (reverse l) ) ;_ lambda (entget ename) ) ) ;_ ssget ) ;_ lambda _ext (lambda (e p) (and (load "extrim.lsp" nil) etrim (not (etrim o p)) ) ;_ and ) ;_ lambda _Pnt (lambda (e s / e o l p) (setq e (vlax-ename->vla-object e)) (setq p (vlax-curve-getendpoint (caar (vl-sort (cons (cons e (vla-get-area e)) (setq l (mapcar (function (lambda (# / o) (if (setq o (car (vlax-safearray->list (vlax-variant-value (vla-offset e (* # 0.000001))) ) ;_ vlax-safearray->list ) ;_ car ) ;_ setq (cons o (vla-get-area o)) ) ;_ if ) ;_ lambda ) ;_ function '(-1. 1.) ) ;_ mapcar ) ;_ setq ) ;_ cons (function (lambda (a b) (s (cdr a) (cdr b)))) ) ;_ vl-sort ) ;_ caar ) ;_ vlax-curve-getendpoint ) ;_ setq (mapcar (function (lambda (x) (vl-catch-all-apply (function vla-delete) (list (car x))))) l ) ;_ mapcar p ) ;_ lambda ) ;_ setq (and (setq o (car (entsel "\nSelect LWPolyline: "))) (or (eq "LWPOLYLINE" (cdr (assoc 0 (setq ent (entget o))))) (alert "Invalid object!") ) ;_ or (not (initget 0 "Inside Outside")) (setq *EIO:Opt* (cond ((getkword (strcat "\nSpecify erase option [inside/Outside] <" *EIO:Opt* ">: "))) (*EIO:Opt*) ) ;_ cond ) ;_ setq (setq u (not (vla-startundomark *AcadDoc*))) (cond ((and (eq *EIO:Opt* "Inside") (setq ssIn (_p2ss o "_WP"))) (_ext o (_pnt o <)) ((lambda (i) (while (setq e (ssname ssIn (setq i (1+ i)))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ while ) ;_ lambda -1 ) ) ((eq *EIO:Opt* "Outside") (_ext o (_pnt o >)) (setq ssIn (_p2ss o "_CP") ssOut (ssget "_X" (list (cons 410 (getvar 'ctab)))) ) ;_ setq ((lambda (i) (while (setq e (ssname ssOut (setq i (1+ i)))) (if ssIn (or (ssmemb e ssIn) (eq o e) (vl-catch-all-apply (function entdel) (list e))) (or (eq o e) (vl-catch-all-apply (function entdel) (list e))) ) ;_ if ) ;_ while ) ;_ lambda -1 ) ) ) ;_ cond ) ;_ and (and *AcadDoc* u (vla-endundomark *AcadDoc*)) (princ) ) ;_ defun ...back to dinner... Quote Link to comment Share on other sites More sharing options...
kasra Posted April 2, 2010 Author Share Posted April 2, 2010 the last you posted was excelent. it works perfect in outside operation. but in inside operation, it looks that need some modification. the clock in Here is 4:06 am . I'm so tired and need sleeping. I 'll be back tomorrow. good luck and have a nice day. Quote Link to comment Share on other sites More sharing options...
lpseifert Posted April 3, 2010 Share Posted April 3, 2010 No mas Roberto Duran Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.