Lee Mac Posted January 26, 2009 Posted January 26, 2009 Hi Guys, Hope you are all having a good day and are not working overly hard (just enough to scrape it). Just a quick question - I'm sure there is someone on here able to answer it - if not, no worries. In relation to this thread: http://www.cadtutor.net/forum/showthread.php?t=31790 I posted the following LISP in response to the posted drawing example in the above thread: ; Diamond ~ by Lee McDonnel [25.01.2009] ; Places a Diamond Block at the Intersection of a LWPolyline ; [Assumes Diamond Block Definition is in Drawing] ; [updated to remove intersecting line] (defun c:diamond (/ ss lEnt eLst sLin eLin pvert i int intLst) (vl-load-com) (if (and (setq ss (ssget '((0 . "LWPOLYLINE")))) (setq lEnt (car (entsel "\nSelect Intersecting Line > "))) (eq (cdr (assoc 0 (entget lEnt))) "LINE")) (progn (setq eLst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))) sLin (cdr (assoc 10 (entget lEnt))) eLin (cdr (assoc 11 (entget lEnt)))) (foreach ent eLst (setq pVert (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 10 (car x))) (entget ent)))) (if (eq (setq i (length pVert)) 4) (progn (while (not (zerop (setq i (1- i)))) (if (setq int (inters sLin eLin (nth i pVert) (nth (1- i) pVert))) (setq intLst (cons int intLst)))) (setq intLst (vl-sort intLst '(lambda (x1 x2) (< (car x1) (car x2))))) (SetBlkTF "3ANSYMB") (entmake (list (cons 0 "INSERT") (cons 2 "3ANSYMB") (cons 10 (cadr intLst)))) (entmake (list (cons 0 "INSERT") (cons 2 "3ANSYMB") (cons 10 (cons (- (caar intLst) 6.5515) (cdar intLst)))))))) (entdel lEnt)) (princ "\n<!> No Line Selected, or this isn't a Line! <!>")) (princ)) (defun SetBlkTF (n) (cond ((not (snvalid n)) (princ "\nInvalid Block Name - " n) (exit)) ((tblsearch "BLOCK" n)) ((findfile (strcat n ".DWG")) (command "_.INSERT" n) (command)) (T ; If all else fails.... (entmake (list (cons 0 "BLOCK") (cons 2 n) (cons 10 (list 0 0 0)) (cons 70 0))) (entmake (list (cons 0 "TEXT") (cons 1 (strcat "BLOCK PLACECARD - " n)) (cons 7 (cdr (assoc 2 (tblnext "STYLE" T)))) (cons 8 "0") (cons 10 (list 0 0 0)) (cons 11 (list 0 0 0)) (cons 40 (max 1 (getvar "TEXTSIZE"))) (cons 72 4))) (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))))n) But, for some unknown reason (documented in the linked thread) the LISP seemed to work on my machine, running ACAD '04 but not on the OP's machine, running '07. I could not think of a reason this should occur, as, in the LISP, I did not use any "command" functions (removing the possibility of a difference in prompt order) and I didn't think AutoLISP had changed that much in 3 years for this to occur. In the end Fixo posted another solution to the problem, using a similar method to insert the required block, however his code functioned correctly on '07. I would appreciate and be grateful to anyone supplying any additional information about why my post was not successful on '07, but successful on '04. Thank you for your time spent in reading this thread and, if you are not already doing so, - have a great day. Cheers, Lee Quote
ReMark Posted January 26, 2009 Posted January 26, 2009 Maybe it was a change to an AutoCAD system variable? http://www.hyperpics.com/system_variables/ Quote
Lee Mac Posted January 26, 2009 Author Posted January 26, 2009 Many thanks for the link ReMark, but I don't think I tamper with any system variables in the LISP - but thanks for the suggestion. Have bookmarked that page for later reference - thanks Quote
ReMark Posted January 26, 2009 Posted January 26, 2009 Error checking? The routine is getting a response it doesn't recognize or isn't expecting and therefore it bombs? Quote
Lee Mac Posted January 26, 2009 Author Posted January 26, 2009 Apparently, according to Jack O'Neill - no error is occurring - the routine just completes after one entity is modified - it seems like the "foreach" is not stepping through the entity list, either that or the ssnamex is not returning a full list of entity names... but obviously these work on '04, so why shouldn't they on '07.... 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.