motee-z Posted June 7, 2012 Posted June 7, 2012 hello can any one help to add a predefined circle or block to each end and start of all arcs in the drawing thanks Quote
Tharwat Posted June 7, 2012 Posted June 7, 2012 What is the diameter of circles or what is the name of the block ? Quote
motee-z Posted June 7, 2012 Author Posted June 7, 2012 hello tharwat any diameter(optional)any block in the drawing command line: select arcs: all arcs selected even polyline if contain circles enter radius of circle or name of block: Quote
Tharwat Posted June 7, 2012 Posted June 7, 2012 Try this at the moment .... (defun c:Test (/ ss i sn ins d bname) ;;; Tharwat 08. June. 2012 ;;; (if (and (setq ss (ssget "_x" '((0 . "ARC")))) (progn (initget "Circle Block") (setq ins (getkword "\n Choose one [Circle/Block] :")) ) ) (progn (if (eq ins "Block") (progn (setq bname (getstring t "\n Enter name of Block :")) (tblsearch "BLOCK" bname) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (foreach p (list (vlax-curve-getstartpoint sn) (vlax-curve-getendpoint sn) ) (entmakex (list '(0 . "INSERT") (cons 2 bname) (cons 10 p) '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) ) ) ) ) ) (progn (if (setq d (getdist "\n Specify Diameter of Circle :")) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (foreach p (list (vlax-curve-getstartpoint sn) (vlax-curve-getendpoint sn) ) (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 d)) ) ) ) ) ) ) ) (princ) ) (princ) ) Quote
Lee Mac Posted June 7, 2012 Posted June 7, 2012 My version for fun: ([color=BLUE]defun[/color] c:carc ( [color=BLUE]/[/color] b c d e f i p r s x ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] s ([color=BLUE]ssget[/color] [color=MAROON]"_X"[/color] '( (-4 . [color=MAROON]"<OR"[/color]) (0 . [color=MAROON]"ARC"[/color]) (-4 . [color=MAROON]"<AND"[/color]) (0 . [color=MAROON]"LWPOLYLINE"[/color]) (-4 . [color=MAROON]"<>"[/color]) (42 . 0.0) (-4 . [color=MAROON]"AND>"[/color]) (-4 . [color=MAROON]"OR>"[/color]) ) ) ) ([color=BLUE]progn[/color] ([color=BLUE]initget[/color] [color=MAROON]"Block Circle"[/color]) ([color=BLUE]if[/color] ([color=BLUE]eq[/color] [color=MAROON]"Circle"[/color] ([color=BLUE]getkword[/color] [color=MAROON]"\nBlock or Circle? <Block>: "[/color])) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] r ([color=BLUE]getdist[/color] [color=MAROON]"\nSpecify Circle Radius: "[/color])) ([color=BLUE]setq[/color] f ([color=BLUE]lambda[/color] ( p ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"CIRCLE"[/color]) ([color=BLUE]cons[/color] 10 p) ([color=BLUE]cons[/color] 40 r))))) ) ([color=BLUE]progn[/color] ([color=BLUE]while[/color] ([color=BLUE]not[/color] ([color=BLUE]or[/color] ([color=BLUE]eq[/color] [color=MAROON]""[/color] ([color=BLUE]setq[/color] b ([color=BLUE]getstring[/color] [color=BLUE]t[/color] [color=MAROON]"\nSpecify Name of Block: "[/color]))) ([color=BLUE]tblsearch[/color] [color=MAROON]"BLOCK"[/color] b) ([color=BLUE]and[/color] ([color=BLUE]setq[/color] d ([color=BLUE]findfile[/color] ([color=BLUE]strcat[/color] b [color=MAROON]".dwg"[/color]))) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] c ([color=BLUE]getvar[/color] 'cmdecho)) ([color=BLUE]setvar[/color] 'cmdecho 0) ([color=BLUE]command[/color] [color=MAROON]"_.-insert"[/color] d [color=BLUE]nil[/color]) ([color=BLUE]setvar[/color] 'cmdecho c) ) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nBlock not found."[/color]) ) ([color=BLUE]if[/color] ([color=BLUE]tblsearch[/color] [color=MAROON]"BLOCK"[/color] b) ([color=BLUE]setq[/color] f ([color=BLUE]lambda[/color] ( p ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"INSERT"[/color]) ([color=BLUE]cons[/color] 10 p) ([color=BLUE]cons[/color] 2 b))))) ) ) ) ([color=BLUE]if[/color] f ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]sslength[/color] s)) ([color=BLUE]setq[/color] e ([color=BLUE]entget[/color] ([color=BLUE]ssname[/color] s ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i)))) x [color=BLUE]nil[/color] ) ([color=BLUE]if[/color] ([color=BLUE]eq[/color] [color=MAROON]"ARC"[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 0 e))) ([color=BLUE]foreach[/color] a '(50 51) (f ([color=BLUE]polar[/color] ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 10 e)) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] a e)) ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 40 e)))) ) ([color=BLUE]while[/color] ([color=BLUE]setq[/color] p ([color=BLUE]assoc[/color] 10 e)) ([color=BLUE]setq[/color] e ([color=BLUE]cdr[/color] ([color=BLUE]member[/color] p e))) ([color=BLUE]if[/color] ([color=BLUE]or[/color] x ([color=BLUE]not[/color] ([color=BLUE]equal[/color] 0.0 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 42 e)) 1e-)) ([color=BLUE]progn[/color] (f ([color=BLUE]cdr[/color] p)) ([color=BLUE]setq[/color] x ([color=BLUE]/=[/color] 0.0 ([color=BLUE]cdr[/color] ([color=BLUE]assoc[/color] 42 e)))) ) ) ) ) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nNo Arcs or PolyArcs found."[/color]) ) ([color=BLUE]princ[/color]) ) Quote
motee-z Posted June 7, 2012 Author Posted June 7, 2012 thank you for tharwat thank you Lee Mac for reply code of Lee Mac works fine but there is a problem at tharwat code thank you both Quote
Tharwat Posted June 7, 2012 Posted June 7, 2012 what is the error message that you have received ? Quote
MSasu Posted June 8, 2012 Posted June 8, 2012 @motee-z: Just add the line below to Tharwat's code: (vl-load-com) Quote
motee-z Posted June 8, 2012 Author Posted June 8, 2012 it works tharwat after adding (vl-load-com) but polylines arcs not considered thank you very much Quote
motee-z Posted June 8, 2012 Author Posted June 8, 2012 mr Lee Mac i tried to add these lines in all possible places to create layer named(markarc) to lay circles on but i failed (command "layer" "make" "arcmark" "") (command "layer" "c" "3" "arcmark" "") (command "color" "bylayer") any suggestion Quote
MSasu Posted June 8, 2012 Posted June 8, 2012 Use this line to add the new layer: (if (not (tblsearch "LAYER" "arcmark")) (entmakex '((0 . "LAYER") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "arcmark") (70 . 0) (62 . 3) (6 . "Continuous"))) ) To get the circles/blocks in desired layer just adjut: (entmake (list '(0 . "CIRCLE") (cons 10 p) (cons 40 r) [color=magenta]'(8 . "arcmark")[/color])) ... (entmake (list '(0 . "INSERT") (cons 10 p) (cons 2 b) [color=magenta]'(8 . "arcmark")[/color])) Quote
Tharwat Posted June 8, 2012 Posted June 8, 2012 @motee-z: Just add the line below to Tharwat's code: (vl-load-com) Thank you Mircea . it works tharwat after adding (vl-load-com)but polylines arcs not considered thank you very much You're welcome . Polylines are not included because you did not ask about them into your first post . Quote
Lee Mac Posted June 8, 2012 Posted June 8, 2012 Polylines are not included because you did not ask about them into your first post . hello tharwatany diameter(optional)any block in the drawing command line: select arcs: all arcs selected even polyline if contain circles enter radius of circle or name of block: .......... Quote
Tharwat Posted June 8, 2012 Posted June 8, 2012 I considered the first post , and I was writing the code when the OP replied to my first post . Anyway , You did a very good routine that I learned how to include Polyline 's arc within the selection set filtration system. Quote
Tharwat Posted June 10, 2012 Posted June 10, 2012 i tried to add these lines in all possible places to create layer named(markarc) to lay circles on but i failed (command "layer" "make" "arcmark" "") (command "layer" "c" "3" "arcmark" "") (command "color" "bylayer") any suggestion Try it now .... (defun c:Test (/ ss i sn ins d bname) ;;; Tharwat 10. June. 2012 ;;; (vl-load-com) (if (and (setq ss (ssget "_x" '((-4 . "<OR") (0 . "ARC") (-4 . "<AND") (0 . "LWPOLYLINE") (-4 . "<>") (42 . 0.0) (-4 . "AND>") (-4 . "OR>") ) ) ) (progn (initget "Circle Block") (setq ins (getkword "\n Choose one [Circle/Block] :")) ) ) (progn (if (not (tblsearch "LAYER" "arcmark")) (entmakex '((0 . "LAYER") (100 . "AcDbSymbolTableRecord") (100 . "AcDbLayerTableRecord") (2 . "arcmark") (70 . 0) (62 . 3) (6 . "Continuous") ) ) ) (if (eq ins "Block") (progn (setq bname (getstring t "\n Enter name of Block :")) (tblsearch "BLOCK" bname) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (foreach p (list (vlax-curve-getstartpoint sn) (vlax-curve-getendpoint sn) ) (entmakex (list '(0 . "INSERT") (cons 2 bname) (cons 10 p) '(8 . "arcmark") '(41 . 1.0) '(42 . 1.0) '(43 . 1.0) ) ) ) ) ) (progn (if (setq d (getdist "\n Specify Diameter of Circle :")) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (foreach p (list (vlax-curve-getstartpoint sn) (vlax-curve-getendpoint sn) ) (entmakex (list '(0 . "CIRCLE") '(8 . "arcmark") (cons 10 p) (cons 40 d) ) ) ) ) ) ) ) ) (princ) ) (princ) ) Quote
Tharwat Posted June 10, 2012 Posted June 10, 2012 thank you tharwat for your effort You're welcome anytime .. Quote
irneb Posted June 11, 2012 Posted June 11, 2012 Lee I like these constructs: ([color=BLUE]setq[/color] f ([color=BLUE]lambda[/color] ( p ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"CIRCLE"[/color]) ([color=BLUE]cons[/color] 10 p) ([color=BLUE]cons[/color] 40 r))))) Though, what would be the difference if you simply used a normal defun statement instead of setq+lambda? Quote
Lee Mac Posted June 11, 2012 Posted June 11, 2012 Lee I like these constructs:([color=BLUE]setq[/color] f ([color=BLUE]lambda[/color] ( p ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"CIRCLE"[/color]) ([color=BLUE]cons[/color] 10 p) ([color=BLUE]cons[/color] 40 r))))) Thank you Irné Though, what would be the difference if you simply used a normal defun statement instead of setq+lambda? To my knowledge, a negligible difference in performance, though, since the function 'f' is different for each option and is created during runtime I felt it more suitable to use an anonymous lambda function rather than using a defun expression. I tend to reserve defun expressions for cases in which the function is static and isolated from the main function (i.e. does not share local variables with the main function). 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.