pBe Posted December 18, 2011 Posted December 18, 2011 I didn't get it, this is a response to alan or my post? whichever it is it hits error: no function definition: VLAX-ENAME->VLA-OBJECT I'm not much into Vlisp yet to debug it Ooops sorry about that You AND Alanjt Add this line: (defun c:IOI (/ AT:TriangleArea ss i ent obj dst off) [color=blue][b](vl-load-com)[/b][/color] [color=#0000ff]....[/color] Quote
fathihvac Posted December 18, 2011 Posted December 18, 2011 It can be done, BUT i will code it to work only with closed polylines. I believe you know what will happen if its not specially with a 2 vertices polyline. Your orignal code shows exclusive selection for ""LWPOLYLINE" BUT we can manage that. (defun c:oi (/ e etyp pto) (vl-load-com) ;;; Lee Mac ;;; (defun LM:ListClockwise-p (lst) (minusp (apply '+ (mapcar (function (lambda (a b) (- (* (car b) (cadr a)) (* (car a) (cadr b))) ) ) lst (cons (last lst) lst) ) ) ) ) (if (setq e (ssget "_+.:S:E" '((0 . "*LINE")))) (progn (if (not dist) (setq dist 1.00) ) (setq dist (cond ((getreal (strcat "\nEnter Distance <" (rtos (abs dist) 2 2) ">: " ) ) ) ((abs dist)) ) ) (setq e (ssname e 0) etyp (cdr (assoc 0 (entget e))) ) (cond ((and (eq etyp "LWPOLYLINE") (> (cdr (assoc 90 (entget e))) 2) ) (vla-put-closed (vlax-ename->vla-object e) :vlax-true) (setq dist (if (LM:ListClockwise-p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10) ) (entget e) ) ) ) dist (* dist -1.0) ) ) (while (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-offset (list (vlax-ename->vla-object e) dist) ) ) ) (setq e (entlast)) ) ) ((eq etyp "LINE") (if (not rep) (setq rep 1) ) (initget 6) (setq d dist rep (cond ((getint (strcat "\nNumber of Offset <" (itoa rep) ">: " ) ) ) (rep) ) pto (getpoint "\nGetpoint Side to offset:") ) (repeat rep (command "._offset" d e pto nil) (setq d (+ d dist)) ) ) ) ) )(princ) ) For one thing , you're on it Hello pBe, Could you modify this code so it allows selecting many object lines ,arcs splines and polyline and offseting them simultanously. Quote
Lee Mac Posted December 18, 2011 Posted December 18, 2011 This was my 'Offset Inside' program: [color=GREEN];; Offset Inside - Lee Mac - www.lee-mac.com[/color] [color=GREEN];; Offsets a set of objects by a specified distance to the inside.[/color] ([color=BLUE]defun[/color] c:OffInside ( [color=BLUE]/[/color] acsel pos ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] *dist* ([color=BLUE]cond[/color] ( ([color=BLUE]getdist[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nOffset Distance"[/color] ([color=BLUE]if[/color] *dist* ([color=BLUE]strcat[/color] [color=MAROON]" <"[/color] ([color=BLUE]rtos[/color] *dist*) [color=MAROON]">: "[/color]) [color=MAROON]": "[/color]) ) ) ) ( *dist* ) ) ) ([color=BLUE]ssget[/color] '( (-4 . [color=MAROON]"<OR"[/color]) (0 . [color=MAROON]"CIRCLE,ARC,ELLIPSE"[/color]) (-4 . [color=MAROON]"<AND"[/color]) (0 . [color=MAROON]"LWPOLYLINE,SPLINE"[/color]) (-4 . [color=MAROON]"&="[/color]) (70 . 1) (-4 . [color=MAROON]"AND>"[/color]) (-4 . [color=MAROON]"<AND"[/color]) (0 . [color=MAROON]"POLYLINE"[/color]) (-4 . [color=MAROON]"&="[/color]) (70 . 1) (-4 . [color=MAROON]"<NOT"[/color]) (-4 . [color=MAROON]"&"[/color]) (70 . 120) (-4 . [color=MAROON]"NOT>"[/color]) (-4 . [color=MAROON]"AND>"[/color]) (-4 . [color=MAROON]"OR>"[/color]) ) ) ) ([color=BLUE]progn[/color] ([color=BLUE]vlax-for[/color] obj ([color=BLUE]setq[/color] acsel ([color=BLUE]vla-get-activeselectionset[/color] ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color])) ) ) ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]vla-offset[/color] ([color=BLUE]list[/color] obj ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] pos ([color=BLUE]vl-position[/color] ([color=BLUE]vla-get-objectname[/color] obj) '([color=MAROON]"AcDbPolyline"[/color] [color=MAROON]"AcDb2dPolyline"[/color]))) (LM:ListClockwise-p (LM:GroupByNum ([color=BLUE]vlax-get[/color] obj 'coordinates) ([color=BLUE]+[/color] pos 2))) ) *dist* ([color=BLUE]-[/color] *dist*) ) ) ) ) ([color=BLUE]vla-delete[/color] acsel) ) ) ([color=BLUE]princ[/color]) ) [color=GREEN];; List Clockwise-p - Lee Mac[/color] [color=GREEN];; Returns T if the point list is clockwise oriented[/color] ([color=BLUE]defun[/color] LM:ListClockwise-p ( lst ) ([color=BLUE]minusp[/color] ([color=BLUE]apply[/color] '[color=BLUE]+[/color] ([color=BLUE]mapcar[/color] ([color=BLUE]function[/color] ([color=BLUE]lambda[/color] ( a b ) ([color=BLUE]-[/color] ([color=BLUE]*[/color] ([color=BLUE]car[/color] b) ([color=BLUE]cadr[/color] a)) ([color=BLUE]*[/color] ([color=BLUE]car[/color] a) ([color=BLUE]cadr[/color] b))) ) ) lst ([color=BLUE]cons[/color] ([color=BLUE]last[/color] lst) lst) ) ) ) ) [color=GREEN];; Group by Number - Lee Mac[/color] [color=GREEN];; Groups a list into a list of lists, each of length 'n'[/color] ([color=BLUE]defun[/color] LM:GroupByNum ( l n [color=BLUE]/[/color] r) ([color=BLUE]if[/color] l ([color=BLUE]cons[/color] ([color=BLUE]reverse[/color] ([color=BLUE]repeat[/color] n ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] ([color=BLUE]car[/color] l) r) l ([color=BLUE]cdr[/color] l)) r)) (LM:GroupByNum l n) ) ) ) ([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color]) Quote
anishtain4 Posted December 18, 2011 Author Posted December 18, 2011 Ooops sorry about that You AND Alanjt Add this line: (defun c:IOI (/ AT:TriangleArea ss i ent obj dst off) [color=blue][b](vl-load-com)[/b][/color] [color=#0000ff]....[/color] I believe something is wrong, it only offsets five time outside, I rather the #6 post yet Quote
pBe Posted December 19, 2011 Posted December 19, 2011 I believe something is wrong, it only offsets five time outside, I rather the #6 post yet Just as I suspected. you have a "seemingly closed" pline use this on your pline: (defun c:test () (cdr (assoc 70 (entget (car (entsel))))) ) command: test select objects: the result will be one of these bit values 0 1 4 128 129 132 133 Like most of the codes on this thread, inifinite will only works with flg 1 But no worries, we can still accomodate your request by testing if first and lastpoint is equal See updated code HTH Quote
pBe Posted December 19, 2011 Posted December 19, 2011 This was my 'Offset Inside' program: I remember this one Lee. AAMOF thats where i got the idea for the code posted at post #9 Quote
Lee Mac Posted December 19, 2011 Posted December 19, 2011 I remember this one Lee. AAMOF thats where i got the idea for the code posted at post #9 It was useful to someone then at least Quote
anishtain4 Posted December 20, 2011 Author Posted December 20, 2011 It's all 0, for all the cases I use As I said your #6 is good, maybe I modify it after I read the lisp bible. I can manage my things for now. I wrote a lisp which do offset five time on an arbitrary side, and changed your code to offset only inside. I get the mixed when I have enough knowledge myself. Quote
alanjt Posted December 20, 2011 Posted December 20, 2011 (defun c:IOI (/ AT:TriangleArea ss i ent obj dst off) ;; Infinite Offset Inward (well, not infinite, but as much as possible, given the offset increment ;; Alan J. Thompson, 12.19.11 (vl-load-com) (defun AT:TriangleArea (a b c) ;; Returns area of three provided points ;; If returned value is negative, last point (c) exists on right side of a-b vector ;; Alan J. Thompson, 06.09.10 (/ (- (* (- (car b) (car a)) (- (cadr c) (cadr a))) (* (- (cadr b) (cadr a)) (- (car c) (car a))) ) 2. ) ) (initget 6) (if (and (setq *IOI:Inc* (cond ((getdist (strcat "\nSpecify inward offset increment" (if (numberp *IOI:Inc*) (strcat " <" (rtos *IOI:Inc*) ">: ") ": " ) ) ) ) (*IOI:Inc*) ) ) (setq ss (ssget "_:L" '((-4 . "<OR") (0 . "ARC,CIRCLE") (-4 . "<AND") (0 . "LWPOLYLINE") (-4 . "&=") (70 . 1) (-4 . "AND>") (-4 . "<AND") (0 . "POLYLINE") (-4 . "&=") (70 . 1) (-4 . "<NOT") (-4 . "&") (70 . 120) (-4 . "NOT>") (-4 . "AND>") (-4 . "OR>") ) ) ) ) (repeat (setq i (sslength ss)) (setq ent (ssname ss (setq i (1- i))) obj (vlax-ename->vla-object ent) dst (if (and (wcmatch (vla-get-objectname obj) "*Polyline") (minusp (AT:TriangleArea (vlax-curve-getPointAtParam ent 0) (vlax-curve-getPointAtParam ent 1) (vlax-curve-getPointAtParam ent 2) ) ) ) *IOI:Inc* (- *IOI:Inc*) ) ) (while (not (vl-catch-all-error-p (setq off (vl-catch-all-apply 'vlax-invoke (list obj 'Offset dst)))) ) (setq obj (car off)) ) ) ) (princ) ) Quote
pBe Posted December 20, 2011 Posted December 20, 2011 It's all 0, for all the cases I use As I said your #6 is good, maybe I modify it after I read the lisp bible. I can manage my things for now. I wrote a lisp which do offset five time on an arbitrary side, and changed your code to offset only inside. I get the mixed when I have enough knowledge myself. Ok Anishtain4, its your call I would suggest you use the code at post#19 where you can select multiple objects , if the its a 1 segment pline it will prompt you to pick the side then proceed on the next one. we can tweak it to prompt for number of repeat like the one on post #6 > Cheers Quote
anishtain4 Posted December 20, 2011 Author Posted December 20, 2011 It's #6, #9 closes the polyline which is not something I want, I don't use multilines because I have to adjust all of my drawings in regard to others, so I have to do them one by one. I just changed the ssget line to "_:L" so if I missed the first click I won't have to repeat the command from the first. Thanks Quote
pBe Posted December 20, 2011 Posted December 20, 2011 FWIW #19 [updated code] doesnt close the polyline as long as first and end point is the same. Anyhoo, you are Welcome anishtain4, at least you have a couple of codes to study [Alanjt/EP/Lee Mac/pBe/tharwat] Have fun Quote
anishtain4 Posted December 20, 2011 Author Posted December 20, 2011 In my experience it closes all of my polylines and then start to offsetting. Yeppppp, I have a lot of codes to study, and thank you all Quote
fathihvac Posted December 20, 2011 Posted December 20, 2011 Hello pBe, Could you modify your code so it allows selecting many object lines ,arcs splines and polyline and offseting them simultanously. Quote
pBe Posted December 21, 2011 Posted December 21, 2011 Hello pBe,Could you modify your code so it allows selecting many object lines ,arcs splines and polyline and offseting them simultanously. Try this first: Lee Mac or Alanjt this thread Quote
fathihvac Posted December 21, 2011 Posted December 21, 2011 Hello pBe, On my ie i can't see the number of post could you it for me ,Thanks Quote
pBe Posted December 21, 2011 Posted December 21, 2011 Hello pBe,On my ie i can't see the number of post could you it for me ,Thanks http://www.cadtutor.net/forum/showthread.php?65124-multiple-offset&p=445594&viewfull=1#post445594 http://www.cadtutor.net/forum/showthread.php?65124-multiple-offset&p=445844&viewfull=2#post445844 Quote
SLW210 Posted December 21, 2011 Posted December 21, 2011 Hello pBe,On my ie i can't see the number of post could you it for me ,Thanks Upgrade your IE to the latest version. Quote
Saqib_theleo Posted February 17, 2012 Posted February 17, 2012 It can be done, BUT i will code it to work only with closed polylines. I believe you know what will happen if its not specially with a 2 vertices polyline. Your orignal code shows exclusive selection for ""LWPOLYLINE" BUT we can manage that. (defun c:oi (/ e etyp pto) (vl-load-com) ;;; Lee Mac ;;; (defun LM:ListClockwise-p (lst) (minusp (apply '+ (mapcar (function (lambda (a b) (- (* (car b) (cadr a)) (* (car a) (cadr b))) ) ) lst (cons (last lst) lst) ) ) ) ) (if (setq e (ssget "_+.:S:E" '((0 . "*LINE")))) (progn (if (not dist) (setq dist 1.00) ) (setq dist (cond ((getreal (strcat "\nEnter Distance <" (rtos (abs dist) 2 2) ">: " ) ) ) ((abs dist)) ) ) (setq e (ssname e 0) etyp (cdr (assoc 0 (entget e))) ) (cond ((and (eq etyp "LWPOLYLINE") (> (cdr (assoc 90 (entget e))) 2) ) (vla-put-closed (vlax-ename->vla-object e) :vlax-true) (setq dist (if (LM:ListClockwise-p (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10) ) (entget e) ) ) ) dist (* dist -1.0) ) ) (while (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-offset (list (vlax-ename->vla-object e) dist) ) ) ) (setq e (entlast)) ) ) ((eq etyp "LINE") (if (not rep) (setq rep 1) ) (initget 6) (setq d dist rep (cond ((getint (strcat "\nNumber of Offset <" (itoa rep) ">: " ) ) ) (rep) ) pto (getpoint "\nGetpoint Side to offset:") ) (repeat rep (command "._offset" d e pto nil) (setq d (+ d dist)) ) ) ) ) )(princ) ) For one thing , you're on it Hi pBe, Hope you remember me, this Lisp is working with Line only. I don't want that Infinite Mode, if I want to select any PLine (or both "Line" and "Pline") then how is this possible? Thanks. Quote
pBe Posted February 17, 2012 Posted February 17, 2012 Welcome to the forum Saqib_theleo, Looks like you heed my advice and posted your request where you got the orignal code. Now. what exactly do you need? What you're asking is not that difficult at all, only, there are a couple of codes (AlanjT/LM/Tharwat/.... ) posted on this thread, i suggest you try them all first and see what code is better suited for your needs (you know what they say about re-inventing the wheel) [bTW: who are these people they cal "THEY" ? is there a building out there with a room that says "THEY" on the door? ] Or maybe, you need an entirely different routine. 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.