anishtain4 Posted December 10, 2011 Posted December 10, 2011 Hi all I'm not much into lisp, but there is a series of commands I do use frequently and it would be a great help if someone can tell me the lisp that I can pack them as one command. I'm sure this is not hard at all for you experts of lisp, thanks in advance. mpedit yes join 0 exit Quote
Tharwat Posted December 10, 2011 Posted December 10, 2011 Maybe things like this ..... (defun c:TesT (/ ss) (if (setq ss (ssget "_:L" '((0 . "*POLYLINE")))) (command "_.pedit" "_m" ss "" "_join" 0.0 "") ) (princ) ) Quote
anishtain4 Posted December 10, 2011 Author Posted December 10, 2011 Thanks, my problem was that I was trying to use Mpedit, which is not a standard command and cannot be called, I wrote my own lisp as: (defun c:pj() (if (setq entset(ssget)) (progn (command "pedit" "multiple" entset "" "yes" "join" 0 "") (princ) ) ) ) but another question rose in my head, when I created this final polyline I want to know it's length, how can I select the outcome of this previous command to apply "li" to it and get the length variable of it? ps: if i'm writing codes not according to some standards I would be glad to know that Quote
Tharwat Posted December 10, 2011 Posted December 10, 2011 This might be better that the use of list to see the length of joined Polylines ... (defun c:TesT (/ ss) (if (setq ss (ssget "_:L" '((0 . "*POLYLINE")))) (progn (command "_.pedit" "_m" ss "" "_join" 0.0 "") (alert (strcat "Length of last joined Polyline is : " " " "< " (rtos (vlax-curve-getDistatPoint (entlast) (vlax-curve-getEndPoint (entlast))) 2) " >" ) ) ) ) (princ) ) Quote
Arin9916 Posted December 10, 2011 Posted December 10, 2011 (defun c:jj( / ss doc ) (defun PTE:ss->obj ( ss / i re ) (if ss (repeat (setq i (sslength ss)) (setq re (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) re)) ) ) ) (setvar 'cmdecho 0) (setq ss (ssget '( (-4 . "<or") (0 . "line,arc") (-4 . "<and") (0 . "lwpolyline") (70 . 0) (-4 . "and>") (-4 . "or>") ) ) ) (vla-startundomark (setq doc(vla-get-ActiveDocument (vlax-get-acad-object)))) (foreach obj (PTE:ss->obj ss) (and (not(vlax-erased-p obj)) (if (= (vla-get-objectname obj)"AcDbPolyline") (command "pedit" (vlax-vla-object->ename obj) "j" ss "" "") (command "pedit" (vlax-vla-object->ename obj) "y" "j" ss "" "") ) ) ) (vla-endundomark doc) (princ) )(vl-load-com) Quote
anishtain4 Posted December 12, 2011 Author Posted December 12, 2011 Arin your lisp is the best, because when I want to attach multiple polylines it works, but i couldn't find out what you did there, and I couldn't managed to add the show length of the final polyline to your lisp, entlast just returns nil to me. It would be the best if you add add some comments to your codes, most of all an identity to first of it, something like: ;;;--- jj.lsp - makes all the selected objects one polyline and measure its length. ;;; ;;; ;;; ;;;--- Copyright 2011 by Arin ;;; All rights reserved. ;;; ;;; ;;; ;;;--- Created on 12/10/11 can you tell me what was your reference for learning lisp? and tharwat I like your codes too Quote
ketxu Posted December 12, 2011 Posted December 12, 2011 Or maybe start from sth like this : (defun c:jj( / ss ss1 oldvl lst i) (setq oldvl (mapcar 'getvar '("cmdecho" "PEDITACCEPT"))) (mapcar 'setvar '("cmdecho" "PEDITACCEPT") '(0 1)) (cond ((setq ss (ssget (list (cons 0 "*POLYLINE,LINE,SPLINE,ARC")))) (vl-load-com) (setq ss1 (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))) i 0) (vlax-map-collection ss1 '(lambda(e)(setq lst (cons (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e)) lst)))) (mapcar '(lambda(x)(princ (strcat "Length of item " (itoa (setq i (1+ i))) " is " (rtos x 2 2) "\n"))) (reverse lst)) (princ (strcat "Total length : " (rtos (apply '+ lst) 2 2))) (command ".PEDIT" "m" ss "" "J" 0 nil) ) ) (mapcar 'setvar '("cmdecho" "PEDITACCEPT") oldvl) (princ) ) You could put Error catch or Undo Mark by yourself Quote
anishtain4 Posted December 12, 2011 Author Posted December 12, 2011 Thanks ketxu, this is all I need Quote
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.