XIJIANGWOO Posted June 9, 2011 Share Posted June 9, 2011 linexp.lspHello Everyone, I would like to use the LinExp lisp that I found here in the forums but I was wondering how to modify it so instead of the user having to select objects, it would simple just explode only all "lines"and not other objects. The lisp is not accurate when exploding different shapes of objects. I know a filter has to be used, I'm just not sure how or where to begin. Is this something that can easily be done? I have no knowledge of autolisp. I am only a novice in other languages. Any help is greatly appreciated. Thank you, Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 9, 2011 Share Posted June 9, 2011 You can not explode Lines ! that is a simplest element same as circle, arc, text you can explode plines, mtext blocks plus much more. Can you explain more what you are trying to do. Quote Link to comment Share on other sites More sharing options...
eldon Posted June 9, 2011 Share Posted June 9, 2011 I think you will find that lines can be exploded. The lisp attached is an adaption of TEXTEXP, which basically exports a WMF image and then re-imports the image as a polyline. It is not perfectly accurate, (the scaling is slightly not 1), and the lineweight changes to 0. But if the OP wants to further adapt it, now is a good opportunity to learn Lisp. Quote Link to comment Share on other sites More sharing options...
XIJIANGWOO Posted June 9, 2011 Author Share Posted June 9, 2011 Thanks for the reply. I am trying to learn lisp. I just thought the linexp lisp could be modified to explode all lines instead of having the user select each line. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 9, 2011 Share Posted June 9, 2011 I think you will find that lines can be exploded. I think that I'll have to agree with BIGAL here. The lisp file didn't attach, but it would be interesting to see what would be considered an exploded LINE entity. -David Quote Link to comment Share on other sites More sharing options...
eldon Posted June 9, 2011 Share Posted June 9, 2011 I think that I'll have to agree with BIGAL here. The lisp file didn't attach, but it would be interesting to see what would be considered an exploded LINE entity. -David I did try it before I posted, so for my setup, I can explode all lines. Whether I would want to go as far as the OP seems to, I would not. A continuous line "exploded" to give a polyline of zero lineweight. The non-continuous linetype "exploded" to give individual polylines. Here is the lisp code as posted ;; ;;; ;;; By Dominic Panholzer ;;; ;;; Modified original TXTEXP.LSP from Express Tools ;;; Copyright © 1999 by Autodesk, Inc. ;; LINEXP.LSP modifications by XANADU ;;; ;;; 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." ;;; ;;; AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. ;;; AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF ;;; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. ;;; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE ;;; UNINTERRUPTED OR ERROR FREE. ;;; ;;; Use, duplication, or disclosure by the U.S. Government is subject to ;;; restrictions set forth in FAR 52.227-19 (Commercial Computer ;;; Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) ;;; (Rights in Technical Data and Computer Software), as applicable. ;;; ;;; ---------------------------------------------------------------- ;;; ;;; External Functions: ;;; ;;; ACET-ERROR-INIT --> ACETUTIL.FAS Intializes bonus error routine ;;; ACET-ERROR-RESTORE --> ACETUTIL.FAS Restores old error routine ;;; ACET-GEOM-ZOOM-FOR-SELECT --> ACETUTIL.FAS Zoom boundry to include points given ;;; ACET-LAYER-LOCKED --> ACETUTIL.FAS Checks to see if layer is locked ;;; ACET-GEOM-PIXEL-UNIT --> ACETUTIL.FAS Size of pixel in drawing units ;;; ACET-GEOM-TEXTBOX --> ACETUTIL.FAS Returns the textbox for any text ;;; ACET-GEOM-MIDPOINT --> ACETUTIL.FAS Returns midpoint between two points ;;; ACET-GEOM-VIEW-POINTS --> ACETUTIL.FAS Returns corner points of screen or viewport ;;; ACET-STR-FORMAT --> ACETUTIL.ARX String builder ;;; ACET-WMFIN --> ACETUTIL.FAS Brings in WMF file ;;; (defun c:linexp (/ grplst getgname blknm FLTR GLST GDICT SS VIEW UPLFT TMPFIL TBX TMPFIL CNT PT1 PT2 ENT TXT TXTYP PTLST ZM LOCKED GNAM vpna vplocked) (acet-error-init (list (list "cmdecho" 0 "highlight" 1 "osmode" 0 "Mirrtext" 1 "limcheck" 0 ) T ) ) ; --------------------- GROUP LIST FUNCTION ---------------------- ; This function will return a list of all the group names in the ; drawing and their entity names in the form: ; ((<ename1> . <name1>) ... (<enamex> . <namex>)) ; ---------------------------------------------------------------- (defun acet-txtexp-grplst (/ GRP ITM NAM ENT GLST) (setq GRP (dictsearch (namedobjdict) "ACAD_GROUP")) (while (setq ITM (car GRP)) ; While edata item is available (if (= (car ITM) 3) ; if the item is a group name (setq NAM (cdr ITM) ; get the name GRP (cdr GRP) ; shorten the edata ITM (car GRP) ; get the next item ENT (cdr ITM) ; which is the ename GRP (cdr GRP) ; shorten the edata GLST ; store the ename and name (if GLST (append GLST (list (cons ENT NAM))) (list (cons ENT NAM)) ) ) (setq GRP (cdr GRP)) ; else shorten the edata ) ) GLST ; return the list ) ; ------------------- GET GROUP NAME FUNCTION -------------------- ; This function returns a list of all the group names in GLST ; where ENT is a member. The list has the same form as GLST ; ---------------------------------------------------------------- (defun acet-txtexp-getgname (ENT GLST / GRP GDATA NAM NLST) (if (and GLST (listp GLST)) (progn (foreach GRP GLST (setq GDATA (entget (car GRP))) (foreach ITM GDATA ; step through the edata (if (and (= (car ITM) 340) ; if the item is a entity name (eq (setq NAM (cdr ITM)) ENT) ; and the ename being looked for ) (setq NLST ; store the ename and name (if NLST (append NLST (list (cons (car GRP) (cdr GRP)))) (list (cons (car GRP) (cdr GRP))) ) ) ) ) ) ) ) NLST ) ; ---------------------------------------------------------------- ; MAIN PROGRAM ; ---------------------------------------------------------------- (if (and ; Are we in plan view? (equal (car (getvar "viewdir")) 0 0.00001) (equal (cadr (getvar "viewdir")) 0 0.00001) (> (caddr (getvar "viewdir")) 0) ) (progn (prompt "\nSelect lines to be EXPLODED: ") (Setq FLTR '((-4 . "<AND") (-4 . "<OR") ; filter for mtext and text (0 . "MTEXT") (0 . "TEXT") (-4 . "OR>") (-4 . "<NOT") (102 . "{ACAD_REACTORS") ; and not leader text (-4 . "NOT>") (-4 . "AND>") ) GLST (acet-txtexp-grplst) ; Get all the groups in drawing GDICT (if GLST (dictsearch (namedobjdict) "ACAD_GROUP") ) SS (ssget); FLTR) CNT 0 ) ;; filter out the locked layers (if SS (setq SS (car (bns_ss_mod SS 1 T))) ) ;if ;; if we have anything left (if SS (progn (setq CNT 0) ; Reset counter (while (setq ENT (ssname SS CNT)) ; step through each object in set (and GLST ; if groups are present in the drawing (setq GNAM (acet-txtexp-getgname ENT GLST)) ; and the text item is in one or more (foreach GRP GNAM ; step through those groups (command "_.-group" "_r" ; and remove the text item (cdr GRP) ENT "" ) ) ) (setq TBX (acet-geom-textbox (entget ENT) 0)) ; get textbox points (setq TBX (mapcar '(lambda (x) (trans x 1 0) ; convert the points to WCS ) TBX ) ) (setq PTLST (append PTLST TBX)) ; Build list of bounding box ; points for text items selected (setq CNT (1+ CNT)) ; get the next text item ); while (setq PTLST (mapcar '(lambda (x) (trans x 0 1) ; convert all the points ) ; to the current ucs PTLST ) ) (if (setq ZM (acet-geom-zoom-for-select PTLST)) ; If current view does not contain (progn ; all bounding box points (setq ZM (list (list (- (caar ZM) (acet-geom-pixel-unit)) ; increase zoom area by (- (cadar ZM) (acet-geom-pixel-unit)) ; one pixel width to (caddar ZM) ; sure nothing will be lost ) (list (+ (caadr ZM) (acet-geom-pixel-unit)) (+ (cadadr ZM) (acet-geom-pixel-unit)) (caddr (cadr zm)) ) ) ) (if (setq vpna (acet-currentviewport-ename)) (setq vplocked (acet-viewport-lock-set vpna nil)) );if (command "_.zoom" "_w" (car ZM) (cadr ZM)) ; zoom to include text objects ) ) (setq VIEW (acet-geom-view-points) TMPFIL (strcat (getvar "tempprefix") "txtexp.wmf") PT1 (acet-geom-midpoint (car view) (cadr view)) PT2 (list (car PT1) (cadadr VIEW)) ) (if (acet-layer-locked (getvar "clayer")) ; if current layer is locked (progn (command "_.layer" "_unl" (getvar "clayer") "") ; unlock it (setq LOCKED T) ) ) (command "_.mirror" SS "" PT1 PT2 "_y" "_.WMFOUT" TMPFIL SS "") (if (findfile tmpfil) ; Does WMF file exist? (progn (command "_.ERASE" SS "") ; erase the orignal text (setq ss (acet-wmfin TMPFIL)) ; insert the WMF file (command "_.mirror" ss "" PT1 PT2 "_y") ) ;progn ) ;if (if LOCKED (command "_.layer" "_lock" (getvar "clayer") "") ; relock if needed ) ;if (if ZM (command "_.zoom" "_p")) ; Restore original view if needed (if vplocked (acet-viewport-lock-set vpna T) ;re-lock the viewport if needed. );if (prompt (acet-str-format "\n%1 object(s) have been exploded to lines." CNT)) (prompt "\nThe line objects have been placed on layer 0.") ) ) ) (prompt "\nView needs to be in plan (0 0 1).") );if equal (acet-error-restore) ; Retsore values (princ) ) (princ) Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 9, 2011 Share Posted June 9, 2011 I would still have to disagree with use of term 'Explode' when used in conjunction with a LINE entity. Sorry -David Quote Link to comment Share on other sites More sharing options...
XIJIANGWOO Posted June 9, 2011 Author Share Posted June 9, 2011 Thanks Eldon for posting. That was my fist attempt at posting code (fail). I am trying to use this lisp so I can explode all stitching linetypes automatically instead of manually. I'm not sure how to change the line "prompt "\nSelect lines to be EXPLODED:" to just explode all lines or at least all lines with a "stitch" linetype. Does that sound like something that would not be feasable? Quote Link to comment Share on other sites More sharing options...
eldon Posted June 9, 2011 Share Posted June 9, 2011 I would still have to disagree with use of term 'Explode' when used in conjunction with a LINE entity. Sorry -David What would you call the process that changes one dashed line into several single short lines divided by spaces? Within the bounds of AutoCAD, I would have thought that a lot of people would be happy with the expression "Explode" Thanks Eldon for posting. That was my fist attempt at posting code (fail). I am trying to use this lisp so I can explode all stitching linetypes automatically instead of manually. I'm not sure how to change the line "prompt "\nSelect lines to be EXPLODED:" to just explode all lines or at least all lines with a "stitch" linetype. Does that sound like something that would not be feasable? Why can you not isolate the lines that you want to explode, by turning off/freezing everything else? Then select all the lines with a window selection. Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 9, 2011 Share Posted June 9, 2011 What would you call the process that changes one dashed line into several single short lines divided by spaces? To segment a line based on it's linetype, well I would call it very inefficient It could be called a plotted line as that is how a vector based application would see it ? -David Quote Link to comment Share on other sites More sharing options...
eldon Posted June 9, 2011 Share Posted June 9, 2011 To segment a line based on it's linetype, well I would call it very inefficient It could be called a plotted line as that is how a vector based application would see it ? -David I like your arguments, but for the rest of us non-purists, we will have to do with "explode", and it appears to be what the OP is desiring to do, however inefficient it seems to be to you Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 9, 2011 Share Posted June 9, 2011 That's cool Quote Link to comment Share on other sites More sharing options...
XIJIANGWOO Posted June 9, 2011 Author Share Posted June 9, 2011 What I'm trying to do is to run the lisp without having the need for user input or selection. Everything in the drawing gets exploded but since lines can't actually be exploded, the linexp simulates an explode which gives me the stitching pattern that I am looking for. I have templates of flat patterns of sheet metal wall boxes. I have a stitching line type representing the stitch required for the bends. I have to stretch the flat pattern to all different lengths and widths. Having the linetype allows me to stretch and still maintain the stitch pattern as opposed to stretching and then manually putting the line pattern back in. Quote Link to comment Share on other sites More sharing options...
XIJIANGWOO Posted June 10, 2011 Author Share Posted June 10, 2011 David, Do you know how I could modify the lisp to automatically "convert the lines" instead of requiring user selection? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted June 10, 2011 Share Posted June 10, 2011 I was confused you can not "explode" a dashed line but you can replace it with multiple line segments to give the look of a single line. this is an arc to chords but is almost there you would need to do every second line so need a skip added to it ; converts an arc to a series of straights ; Alan H 2011 (defun c:test (/ oldecho obj div endpt totlen arclen chrdpt dist newpt) (vl-load-com) (setq oldecho (getvar "cmdecho")) (setvar "cmdecho" 0) (setq ent (entsel "\nPick arc: ") obj (vlax-ename->vla-object (car ent)) div (getint "\nEnter number of chords: ") endpt (vlax-curve-getEndPoint obj) totlen (vlax-curve-getDistAtPoint obj endpt) arclen (/ totlen div) chrdpt (vlax-curve-getPointAtDist obj 0) dist 0 ) (repeat div (setq newpt(vlax-curve-getPointatDist obj (+ arclen dist))) (command "line" chrdpt newpt "") (setq dist (+ arclen dist)) (setq chrdpt newpt) );repeat (setvar "cmdecho" oldecho) (princ) );defun Quote Link to comment Share on other sites More sharing options...
XIJIANGWOO Posted June 10, 2011 Author Share Posted June 10, 2011 I have no idea how to modify code in lisp. Would it be an easier task to modify the linexp lisp to select all lines instead of having the user pick each and every line? Quote Link to comment Share on other sites More sharing options...
David Bethel Posted June 10, 2011 Share Posted June 10, 2011 Try replacing this line of code: SS (ssget); FLTR) With this line of code: SS (ssget "X" '((0 . "LINE"))) ; FLTR) -David Quote Link to comment Share on other sites More sharing options...
XIJIANGWOO Posted June 10, 2011 Author Share Posted June 10, 2011 Thank you David ! I've been trying for days to figure out what I need to change in the LISP and it turns out to be just 1 line of characters that need to be modified. I appreaciate all your efforts. Thanks everyone ! Quote Link to comment Share on other sites More sharing options...
luiscarneirorm Posted November 22, 2011 Share Posted November 22, 2011 Hi, Can someone help me? I've been researching this to try to resolve my problem but have not found any solution My goal it's explode some linetypes (DASHED, DASHDOT, ...) to simple lines. I've done it manually but I lose too much time on this The original lines is in the "before_explode" file, and the treated file it's the "after_explode"... Tanks in advance. before_explode.dxf after_explode.dxf Quote Link to comment Share on other sites More sharing options...
alanjt Posted November 22, 2011 Share Posted November 22, 2011 You can make a copy of the TextExplode Express Tool (txtexp.lsp) file, add (0 . "LINE") to the selection filter and it will work as you want. Since it's copyrighted material, I will not edit or post for you. 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.