raj patel Posted October 1, 2015 Posted October 1, 2015 i have a 3D object in autocad and i want to create selection set of line, circle, arc, polyline of that object using visual lisp. please help.. thanks in advance... Drawing1.dwg Quote
satishrajdev Posted October 1, 2015 Posted October 1, 2015 For Example :- Selection set of circle:- (ssget '((0 . "circle"))) Selection set of polyline:- (ssget '((0 . "*polyline"))) Selection set of arc:- (ssget '((0 . "arc"))) and you can combine them like this:- (ssget '((0 . "arc,circle,line,*polyline"))) Quote
ttray33y Posted October 1, 2015 Posted October 1, 2015 i have a 3D object in autocad and i want to create selection set of line, circle, arc, polyline of that object using visual lisp.please help.. thanks in advance... [ATTACH]55664[/ATTACH][ATTACH]55664[/ATTACH] what are you trying to accomplish upon selecting those entity? do you just want to select them? (setq selset (ssget (list (cons -4 "<OR") (cons 0 "ARC") (cons 0 "CIRCLE") (cons 0 "ELLIPSE") (cons 0 "LINE") (cons 0 "LWPOLYLINE") (cons 0 "POINT") (cons 0 "POLYLINE") (cons -4 "OR>") ) ) ) anyway in your attached drawing, i cant find any entity there except the 3D solid object. Quote
raj patel Posted October 1, 2015 Author Posted October 1, 2015 sir, i have a 3D solid object so first what i do to convert them in a any entity? Quote
ttray33y Posted October 1, 2015 Posted October 1, 2015 sir, i have a 3D solid object so first what i do to convert them in a any entity? if you are familiar with SOLPROF command you can accomplish that but if your not, here we go, it is faily easy. Open your drawing, go to any of your Layout Create a Viewport > Single "choose a view you want to have a 2D profile" type MSPACE > ENTER Use SOLPROF > ENTER > Select 3D Solid > ENTER > ENTER > ENTER now goto Model Space and move your 3D object so you can see the 2D profile see snapshot upper > 2D profile lower > 3D Object by the way, you need to explode the 2d profile so you can change the linetype etc. Quote
Hippe013 Posted October 1, 2015 Posted October 1, 2015 I believe what the OP wants to achieve is extracting the edges of the solid. The use of SOLIDEDIT would achieve this. Quote
raj patel Posted October 2, 2015 Author Posted October 2, 2015 I believe what the OP wants to achieve is extracting the edges of the solid. The use of SOLIDEDIT would achieve this. i want feature extraction like as shown attached file(doc1.docx) using autocad and visuallispDoc1.docx Quote
Hippe013 Posted October 6, 2015 Posted October 6, 2015 To the best of my knowledge it is not possible to extract the edges of a solid using lisp. Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 sure there is. I put this together from another lisp so you'll have to go through and adjust but it's a start ( (lambda ( e / g ) (if e (progn (setq g (entget (cdr (assoc 360 (entget (cdr (assoc 350 (entget e)))))))) (mapcar (function cdr) (vl-remove-if-not (function (lambda ( x ) (eq (car x) 360) ) ) g ) ) ) ) ) (car (entsel "\nSelect a solid: ")) ) Quote
Hippe013 Posted October 6, 2015 Posted October 6, 2015 Are you saying that what is left is a list of assoc 360 entities and that these entities are the edges of the solid? I ran your code, with some edits, and I am left with just one entity ACAD_EVALUATION_GRAPH. Could you explain more as to what your code is doing? Quote
Lt Dan's legs Posted October 6, 2015 Posted October 6, 2015 I fear I'm mistaken. I was sure this would bring back results. (I'm embarrassed). This doesn't mean the information you seek cannot be accessed via lisp. It just means I'm not the man for this job. Sorry for the quick uneducated response Quote
raj patel Posted October 7, 2015 Author Posted October 7, 2015 (edited) the programme listed below extract hole in the 3D drawing. can i extract other type of hole(squre or triangle) using this code with some modification. (vl-load-com) (defun c:test (/ i e p1 p2 ss lst q var f fn dat dat1) ;hanhphuc 2014 (set 'var (getvar 'cmdecho )) (setvar 'cmdecho 0) (if (and (setq e (entsel "\nPlease select solid.. ")) (setq e (car e)) (= (cdr (assoc 0 (entget e))) "3DSOLID")) (progn (vla-GetBoundingBox (setq obj (vlax-ename->vla-object e)) 'p1 'p2) (mapcar ''((a b) (set a (vlax-safearray->list b))) '(p1 p2) (list p1 p2)) (command "_explode" e) (setq i 0 ss (ssget "C" p1 p2) lst (mapcar '(lambda(x) (setq q nil) (if (= (cdr (assoc 0 (entget x))) "REGION") (setq q (cons (LM:reg x) q)) (setq q (cons (vlax-ename->vla-object x) q)) ) (if (listp q) (LM:flatten q) q ) ) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) ) ;_ end of mapcar ) ;_ end of setq (foreach o (vl-remove-if-not ''((x) (= (vla-get-ObjectName x) "AcDbCircle")) (LM:flatten lst)) (setq dat(cons (princ (strcat "\nCIRCLE_" (itoa (setq i (1+ i))) " " (vl-princ-to-string (mapcar ''((x)(vlax-get o x)) '(Radius Center)) ))) dat)) ) ;_ end of foreach (command "_.U") (setq fn (strcat (getvar "dwgprefix") "hole dat.csv") f (open fn "w")) ; If you don't want to override file ,to append use (open fn "a") as suggested by Marko @ post#14 (foreach $ (foreach x dat (setq dat1 (cons (vl-string-translate " " "," (vl-list->string (vl-remove-if ''((a) (or (= a 10) (= a 40) (= a 41))) (vl-string->list x)) ) ;_ end of vl-list->string ) ;_ end of vl-string-translate dat1 ) ;_ end of cons ) ;_ end of setq ) ;_ end of foreach (write-line $ f)) (write-line " " f) (if f (close f)) (startapp "notepad" fn) ;<--remove this line if you don't want it to pop-up everytime ) ;_ end of progn ) ;_ end of if (setvar 'cmdecho var) (princ) ) ;_ end of defun ;;;[url]http://www.cadtutor.net/forum/showthread.php?35506-How-to-get-Region-coordinates/page2[/url] ;;;adopted as sub-function (defun LM:reg (reg / RetObj) (setq Reg (vlax-ename->vla-object reg)) (if (vlax-method-applicable-p reg 'explode) (progn (setq RetObj (vlax-safearray->list (vlax-variant-value (vla-explode Reg)))) (repeat (length RetObj) (if (eq "AcDbRegion" (vla-get-ObjectName (car RetObj))) (setq RetObj (append RetObj (vlax-safearray->list (vlax-variant-value (vla-explode (car RetObj)))))) (setq RetObj (append RetObj (list (car RetObj)))) ) ;_ end of if (setq RetObj (cdr RetObj)) ) ;_ end of repeat ) ) retobj ) ;_ end of defun ;; Flatten List - Lee Mac ;; Transforms a nested list into a non-nested list ;; [url]http://www.lee-mac.com/flatten.html[/url] (defun LM:flatten ( l ) (if (atom l) (list l) (append (LM:flatten (car l)) (if (cdr l) (LM:flatten (cdr l)))) ) ) Edited January 11, 2016 by SLW210 Code Tags 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.