samifox Posted May 10, 2013 Author Posted May 10, 2013 (edited) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) ) (mapcar (function (lambda (p) (cons 10 p))) lst)))) here you create a new entity 1.why you use entmakex and not entmake? 2.why you created a new entity and didnt use addline()? 3. what excactly you are doing in the last expression (mapcar (function (lambda (p) (cons 10 p))) lst)))) (defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) i didnt see any list with the name "m" , i dont get why you need sqrt of 2? and what those nums 0.25, 0.75.1.75? really i need your help in those expessions, all the rest are wel documented Thanks Shay Thanks Shay Edited May 10, 2013 by samifox Quote
samifox Posted May 12, 2013 Author Posted May 12, 2013 PBS migal Mac lee please your help I'm stuck in that point Quote
pBe Posted May 13, 2013 Posted May 13, 2013 (defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) i didnt see any list with the name "m" , i dont get why you need sqrt of 2? and what those nums 0.25, 0.75.1.75? really i need your help in those expessions, all the rest are wel documented m variable is the index number for the value to be use as a multiplier for pi to derive the angle i want the point to project to. (nth m '(0.25 0.75 1.25 1.75)));-- if m is 2, you'll get 1.25 where (* pi 1.25) is the radian equivalent of 225 degress. Depending on points selected, you need to set the conditions [angles/distance] for polar arguments. (* d (sqrt 2)) Isosceles right angled triangle: One right angle Two other equal angles always of 45° Two equal sides Ratio 1:1:√2 Say vertical/Horizontal distance is 2 2x√2 will give you the length of Hypotenuse (* d (sqrt 2); 1.why you use entmakex and not entmake? Its basically the same. The main difference is the assignment of "owner" wherein with entmakex you have to set an owner after creation. Not sure if that still holds true for newer versions of Autocad. I think majority of programmers tend to use entmake so go ahead and do so. 2.why you created a new entity and didnt use addline()? CAD Panacea:rkmcswain command-vs-entmake-vs-vla-add.html 3. what excactly you are doing in the last expression (setq [b][color="#8b0000"]lst[/color][/b] '((1.0 2.0 0.0)(5.3 2.6 0.0))) (mapcar (function (lambda (p) (cons 10 p))) [b][color="#8b0000"]lst[/color][/b]) (([b][color="blue"]10[/color][/b] 1.0 2.0 0.0) ([b][color="blue"]10[/color][/b] 5.3 2.6 0.0)) Got it? Quote
samifox Posted May 14, 2013 Author Posted May 14, 2013 OK i setted a breakpoint and follow the intepeter pl get the selected entity name and store all its vertices coordinates in pts list (if (setq pl (car (entsel "\nSelect Pline:"))) (progn (setq pts (mapcar 'cdr ( '(lambda (e) (= (Car e) 10))(entget pl)))) then for each member of the pts list you create point and add it to the temp selection set (setq temp (ssadd)) (foreach p pts (command "_point" "_non" p) (ssadd (entlast) temp)) here,you select all points in the drawing and that where i get lost! what is pn? why you use while loop if you gave it nil? (While (setq corners nil pn (ssget '((0 . "POINT")))) (repeat 2 (setq corners (cons (cdr (assoc 10 (entget (ssname pn 0)))) corners) ) (ssdel (ssname pn 0) pn)) (setq corners (If (> (Cadr (car corners))(Cadr (cadr corners))) (reverse corners) corners )) (setq ang (angle (setq 1p (car corners))(setq 2p (cadr corners)))) (setq mid (mapcar '(lambda (x y) (* 0.5 (+ x y))) 1p 2p)) (Setq h (- (car 2p)(car 1p)) v (- (cadr 2p) (cadr 1p))) (setq pts_ (vl-sort (list 1p (list (car 1p) (cadr 2p)) 2p (list (car 2p) (cadr 1p)) ) '(lambda (a b) (cond ((> (cadr a) (cadr b)) T) ((equal (cadr a) (cadr b) 0.1) (< (car a) (car b))) ) ) ) ) would you help me to gain control again ? Shay Quote
pBe Posted May 14, 2013 Posted May 14, 2013 OK i setted a breakpoint and follow the intepeter... Did you understand the answers to your first set of questions? ......that where i get lost! what is pn? why you use while loop if you gave it nil? The nil is for corners variable, pn is the selection set ..... would you help me to gain control again ? In what way and what part? Quote
samifox Posted June 3, 2013 Author Posted June 3, 2013 Hi I following your code, I learned much more than any boom:) The code start by selecting a poliline Getting its vertices definition Creating point based on the coordinates Selecting 2 points Get the points coordinates And than you said if point 1 is higher than point 2 than reverse the list, why? And than you got into mathematics I got totally lost (not in understanding the code but understanding the math) I get to the part wher the Setq mid(sorry I'm on stupid iPad can't copy paste) As I understand you add the x of point 1 to the x of point 2 and then devide it by helf, why? Thanks Shay Quote
samifox Posted June 10, 2013 Author Posted June 10, 2013 just remind you pBe that someone in this world waiting each day for you reply Quote
LibertyOne Posted June 10, 2013 Posted June 10, 2013 samifox just out of curiosity, in what country are you planning/making reinforcement/rebar drawings? Although you've gotten quite far with your program, perhaps another aproach may help you get to where you want to be. I've spent a couple years doing reinforced concrete drawings and not trying to make it sound easy, but it is really just a lot of math and looking up data in a table or two. There are however a long list of "rules" to go by which are standards for how and where to place the rebar. You have to coinsider bar sizes, bending rollers, lap lengths, concrete cover, etc. I went through a three year apprenticeship with a large German construction company and worked on many high rise buildings made of reinforced concrete. I'd be glad to help and it would be a great learning experience to even program something like this. Quote
samifox Posted June 10, 2013 Author Posted June 10, 2013 Hi I'm from Israel. I'm investing great deal of time learning how to costumize autocad in any aspect, and I still didn't lost hope finding a ready to use solution, but with all the security needs and standarts that we have here. It's really not easy to find. It would be great if you can help me to find such a ready made package. If you like I can send you some sample drawing and try to explain my needs. Thanks for your interests Shay Quote
LibertyOne Posted June 10, 2013 Posted June 10, 2013 There are many reinforcement packages on the market. The first one that comes to mind and is AutoCAD compatible: http://www.sofistik.com/no_cache/en/solutions/soficad/soficad-reinforcement/ Autodesk even now has a reinforced concrete addon: http://www.autodesk.com/products/autocad-structural-detailing/overview Quote
pBe Posted June 12, 2013 Posted June 12, 2013 Hi....And than you said if point 1 is higher than point 2 than reverse the list, why? .....And than you got into mathematics I got totally lost (not in understanding the code but understanding the math) ....As I understand you add the x of point 1 to the x of point 2 and then devide it by helf, why? just remind you pBe that someone in this world waiting each day for you reply Still a demo [with comments] Should work for all four corners: [diagonal points] (defun c:demo ( / LWPoly _from pl pts temp corners ang mid v h 1p 2p l1 l2 objrot) ;;; Demo by pBe 06May2013 ;;; (setvar 'pdmode 34) (setvar 'cmdecho 0) (defun LWPoly (lst) (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 (length lst)) ) (mapcar (function (lambda (p) (cons 10 p))) lst)))) ;;; pBe05Nov2012 ;;; (defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) (if (setq pl (car (entsel "\nSelect Pline:"))) (progn (setq pts (mapcar 'cdr (vl-remove-if-not '(lambda (e) (= (Car e) 10))(entget pl)))) (setq temp (ssadd)) (foreach p pts (command "_point" "_non" p) (ssadd (entlast) temp)) ;;; Select twp point entity to process ;;; (While (setq corners nil pn (ssget '((0 . "POINT")))) ;;; retrieve "point" entity insertion point [DXF 10] ;;; ;;; assign values to corners variable ;;; (repeat 2 (setq corners (cons (cdr (assoc 10 (entget (ssname pn 0)))) corners)) (ssdel (ssname pn 0) pn)) ;;; Get the angle between two "point" entity insertion points ;;; (setq ang (angle (setq 1p (car corners))(setq 2p (cadr corners))) xp 1p); use later to determine lower Y coordinate ;;; Get the mid pointe between two "point" entity insertion points ;;; (setq mid (mapcar '(lambda (x y) (* 0.5 (+ x y))) 1p 2p)) ;;; Horizontal and vertical distance between the "point" entities ;;; (Setq h (Abs (- (car 2p)(car 1p))) v (abs (- (cadr 2p) (cadr 1p)))) ;;; Determine the point with he lower [b]X[/b] coordinate and assign ;;; ;;; the coordinate to variable 1p. [*****] ;;; (if (> (car 1p)(car 2p)) (setq 1p 2p 2p xp)) ;;; Determine coordinate 2.5 away [H/V] from 1p ;;; (setq st ( _pBe:from 1p 2.5 0) objrot (ssadd); variable selection set for rotation tr 0) ; boole argument ;;; 1p from this point ;;; ;;; 2.5 Vertical and horizontal distance from point 1p ;;; ;;; 0 , argument m as nth index number 0< first element ;;; (setq l1 (list (polar st (/ pi 2.0) 100) st (setq 3p (polar st 0 (- h 5.0))) (polar 3p (/ pi 2.0) 100) ) l2 (list (polar st 0 100) st (setq 3p (polar st (/ pi 2.0) (- v 5.0))) (polar 3p 0 100) )) (foreach pts (list l1 l2)(LWpoly pts)(ssadd (entlast) objrot)) ;;; if statement is true then the points are either lower left ;;; ;;; or upper right. go ahead and flip the objects ;;; (if (not (or (< 0.0 ang (/ pi 2.0)) ; between 0 and 90 (< pi ang (* pi 1.5)))); between 180 and 270 (command "_mirror" objrot "" "_non" 1p "_non" (polar 1p 0 1.0) "_yes") ) (prompt "\nMove Mouse up and down to rotate") (while (progn (setq gr (grread t 15 0) mode (car gr) data (cadr gr) ) ;;; pBe 11Oct2010 ;;; (cond ((= 5 mode) (if ((if (zerop tr) < > ) pi (angle mid data) ) (setq tr (boole 6 1 tr) ro (command "_rotate" objrot "" "_non" mid 180) ) ) T ) ((member mode '(2 3)) nil) ) ) ) ) (command "_erase" temp "") ) )(princ) ) Quote
samifox Posted June 15, 2013 Author Posted June 15, 2013 hello Patrick i understand that the following function the final coordinates before you send it to entmakex() but i dont understand the math. (defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) i look in this: http://en.wikipedia.org/wiki/File:Degree-Radian_Conversion.svg but still dont get it thanks Shay Quote
Lee Mac Posted June 15, 2013 Posted June 15, 2013 i understand that the following function the final coordinates before you send it to entmakex() but i dont understand the math.(defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) Perhaps the following image will help to explain the function parameters: Quote
samifox Posted June 15, 2013 Author Posted June 15, 2013 thanks LEE i think i got it (i think P and m=0 should be at the same location???) define a point that is (3.1415926 x 2.5 = 0.78539815) in its angle, and (2.5 x (sqrt 2 = 1.414213562373095) = 3.535533905932738) units its defines the corners of the rebars so i can describe this function as a function to define offset point in a square fashion ? where and how pbe took 0.25 0.75 1.25 1.75? are they constant too? Are you really a Quantum Mechanic ? Quote
pBe Posted June 15, 2013 Posted June 15, 2013 hello Patrick i understand that the following function the final coordinates before you send it to entmakex() but i dont understand the math. Shay Perhaps the following image will help to explain the function parameters: As Lee already pointed out with an illustration It gives you the coordinates from a given point with distance and index number as argument. So with this line (pBe:from point1 2.5 0) (polar p; <---- given point [in this case point1 assigned to variable p (* pi (nth m ; <---- index number [in this case 0 is assigned to variable m '(0.25 0.75 1.25 1.75) ;<--- index number 0 i=on this list is 0.25 ;<--- 0.25 X pi will give you the radians value of ;<-- 0.785398 equivalent to 45 Degrees ;; Note: you can use the value 0.7853981633974483 in place of that, but ;; for higher precision we used math (* pi num) ;; you can write it the way you want, even (/ pi 4.0) (* d (sqrt 2));<-- now for the distance ;<-- 2.5 is assigned to varable d ;<-- by using this you will be able to determine ;<-- the vertical and horizontal distance d from point p You can however use any of this to get the same result (setq p1(polar p 0 d) p2 (polar p1 (/ pi 2.0) d)) or (setq p1 (polar p (/ pi 2.0) d) p2 (polar p1 0 d)) or (setq p1 (list (+ (car p) d)(+ (cadr p) d) (last p))) But that is just for one direction: so the other way around would be 135 degrees (setq p1(polar p pi d) p2 (polar p1 (/ pi 2.0) d)) or (setq p1 (polar p (/ pi 2.0) d) p2 (polar p1 pi d)) or (setq p1 (list (- (car p) d)(+ (cadr p) d) (last p))) As you can see there are too many variables and arguments to keep track of: (setq p1 (list (arg1 (car arg3) arg4)(arg2 (cadr p) arg4) (last arg1)) Also this: (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) can also be written as (polar arg1 (* pi arg2;<--- 0.25 for ex. (* arg3 (sqrt 2)) (pBe:from point1 2.5 0.25) Got it? Kudos to LM for the illustration ...its defines the corners of the rebars...... Yes it does so i can describe this function as a function to define offset point in a square fashion ? You can llok at it that way yes. ......where and how pbe took 0.25 0.75 1.25 1.75? are they constant too? Look at first couple of comments above.... Lee... Are you really a Quantum Mechanic ? Then that makes forum deity as my occupation then Quote
samifox Posted June 15, 2013 Author Posted June 15, 2013 Hi I tryied to code it I draw a rectangle and than I want the code to start building 2.5 offset rectangle that is inside the exist one (setvar 'pdmode 34) (defun C:DO(/ lst pl ) (setq pl (car (entsel "\nSelect Pline:"))) (setq lst (makeCrdList pl)) (setq oset ( _pBe:from (nth 0 lst) 2.5 0)) (setq tot (append lst oset)) (foreach pt tot (command "_point" "_non" pt) ) ) (defun makeCrdList(ent / lst) (setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (e) (= (Car e) 10))(entget ent)))) ) (defun _pBe:from (p d m) (polar p (* pi (nth m '(0.25 0.75 1.25 1.75))) (* d (sqrt 2)) ) ) I was expecting to see additional point that located 2.5 units vertically and horizontally off the first point in the list. Thanks Shay Quote
pBe Posted June 15, 2013 Posted June 15, 2013 You got it all mixed up Shay. First argument is a point coordinate (p d m) 2nd is the Horizontal and Vertical distance from first argument [a point coordinate] (p d m) 3rd is the index number (p d m) further demonstration: (defun C:demo (/ lst pl) (setq pl (car (entsel "\nSelect Pline:"))) (setq lst (makeCrdList pl)) (foreach pt lst (foreach itm '(0 1 2 3) (command "_point" "_non" (_pBe:from pt 2.5 itm)) ) ) ) see what happens. Quote
Lee Mac Posted June 15, 2013 Posted June 15, 2013 i think i got it(i think P and m=0 should be at the same location???) No, the parameter p is the base point for the polar function and with the index parameter m set to zero, the angle argument of the polar function will be π/4 radians (45 degrees) returning the point as correctly indicated on my diagram. Please study the documentation on the polar function: http://exchange.autodesk.com/autocad/enu/online-help/browse#WS1a9193826455f5ff1a32d8d10ebc6b7ccc-6985.htm Personally, I would use: (mapcar '+ p (list d d)) Kudos to LM for the illustration Thank you pBe Quote
pBe Posted June 15, 2013 Posted June 15, 2013 Personally, I would use: (mapcar '+ p (list d d)) Yes. as i demonstrated on post # 35 [exclusively for 45 degree angle].... and among other things.. Thank you pBe Anytime LM. Quote
pBe Posted June 15, 2013 Posted June 15, 2013 Here's a challenge for you Lee. from a given point define the points of a nth polygon. [of course without using the native polygon command] at a given diameter [inscribed]. (_pgon pt 7 10); where pt is the center 7 is the number of sides and 10 is the diameter. 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.