Wojciech Posted March 11, 2014 Share Posted March 11, 2014 Hi! I am on this forum for almost two months, and you helped me with some problems for which I thank You very much. From the beginning I was thinking of a some script, which probably is not so simple to write. I think, it utilize needs a little math (tangent to a circle) and the length of the polyline. I spend a lot of hours to draw perpendicular lines to lines, arc and polylines using function mirror etc. It would be great if it would work as an offset function in AutoCAD. The last picture shows the auxiliary dimensions. Every second line has a length of eg 20. I hope, it is not so difficult to help.. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 11, 2014 Share Posted March 11, 2014 Try this . (defun c:test (/ s d i l ang sn pt) ;; Tharwat 11. Mar. 2014 ;; (if (setq s (ssget "_+.:S:E" '((0 . "LWPOLYLINE,SPLINE,LINE,ARC")))) (progn (setq d (/ (vlax-curve-getdistatparam (setq sn (ssname s 0)) (vlax-curve-getendparam sn) ) 1.5 ) i 1.5 n i l '(1.5 7.0) ) (repeat (fix d) (setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv sn (vlax-curve-getparamatpoint sn (setq pt (vlax-curve-getpointatdist sn n)) ) ) ) n (+ n i) ) (entmake (list '(0 . "LINE") (cons 10 pt) (cons 11 (polar pt (+ ang (* pi 0.5)) (car (setq l (reverse l)))) ) ) ) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
Wojciech Posted March 11, 2014 Author Share Posted March 11, 2014 Thank You! You are so quick! I'm ashamed to ask for fine-tuning. Could you make 4 things? - give the opportunity to choose which side of the line to be created, - draw lines in "test" layer, - give the opportunity to specify a retirement home, length of the first line - now this is 1.5 (I wold like to select between 0 and 1.5 to adapted to other modules). - give the opportunity to specify "beginning" of the polyline Last three supplication is not much needed, but cool! (it's make fully comfortable script). Specify side of drawing lines is important. Thank You! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 11, 2014 Share Posted March 11, 2014 I am too much tired now and it is time to bed here since that it is 10 minutes past midnight , so maybe tomorrow would continue if no one step in and give you a hand to what you are in need of these modifications Quote Link to comment Share on other sites More sharing options...
Wojciech Posted March 11, 2014 Author Share Posted March 11, 2014 (edited) Ok. Thank You! I guess that if I wanted to select the start of the polyline, and this will be the beginning of another polyline, my polyline will have to be on top to select it. Edited March 11, 2014 by Wojciech Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 (edited) Here we go with a great dynamic presentation . (defun c:test (/ *error* Draw_Dynamic_Real s ang sn pt a b d g p gp len x) ;; Tharwat 12. Mar. 2014 ;; (defun *error* (x) (redraw) (if (wcmatch (strcase x) "*EXIT*,*CANCEL*,*BREAK*") (princ x) (princ (strcat "\n Error: " x)) ) ) (if (and (setq p (getpoint "\n Specify point at the End Side of Polyline :")) (if (setq s (ssget p '((0 . "LWPOLYLINE,SPLINE,LINE,ARC")))) t (Alert "Pick a point at the end of [ LWPOLYLINE,SPLINE,LINE,ARC ] only .") ) ) (progn (defun Draw_Dynamic_Real (sn o x sp r / d i n l ang pt) (setq d (/ (vlax-curve-getdistatparam sn (vlax-curve-getendparam sn)) o) i o l (list (* o 0.5) (* o 1.5)) ) (if (> sp 0.) (setq n sp) (setq n i) ) (repeat (fix d) (setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv sn (vlax-curve-getparamatpoint sn (setq pt (vlax-curve-getpointatdist sn n))) ) ) n (+ n i) ) (if r (entmake (list '(0 . "LINE") (cons 8 "test") (cons 10 pt) (cons 11 (polar pt (if x (+ ang (* pi 0.5)) (+ ang (* pi 1.5)) ) (car (setq l (reverse l))) ) ) ) ) (grdraw pt (polar pt (if x (+ ang (* pi 0.5)) (+ ang (* pi 1.5)) ) (car (setq l (reverse l))) ) 1 0 ) ) ) (princ) ) (setq d 1.5 len (vlax-curve-getdistatparam (setq sn (ssname s 0)) (vlax-curve-getendparam sn)) ) (if (< (distance (setq a (vlax-curve-getstartpoint sn)) p) (distance (setq b (vlax-curve-getendpoint sn)) p) ) (setq p a gp 0. ) (setq p b gp (rem len d) ) ) (while (eq (car (setq g (grread t 13 0))) 5) (redraw) (if (minusp (sin (- (angle p (polar p (angle b a) (/ len 1000.))) (angle p (cadr g))))) (setq x nil) (setq x t) ) (Draw_Dynamic_Real sn d x gp nil) ) (if (eq (car g) 3) (Draw_Dynamic_Real sn d x gp t) ) ) ) (redraw) (princ) ) (vl-load-com) Edited March 13, 2014 by Tharwat Quote Link to comment Share on other sites More sharing options...
shailujp Posted March 12, 2014 Share Posted March 12, 2014 Tharwat, Dynamic presentation is indeed fantastic. BTW what software did you use to create this? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 Tharwat, Dynamic presentation is indeed fantastic. BTW what software did you use to create this? Thanks It is Camtasia . Quote Link to comment Share on other sites More sharing options...
Wojciech Posted March 12, 2014 Author Share Posted March 12, 2014 Hi Tharwat! I have problem with your second script. I dont know why it was working only on first time in first file, but after that, it's not working.. First script works! I am putting "test" text in command window, than I see "Specify point at the End Side of Polyline ", after I click, I see "Specify Offset distance", I put 1.5. click Enter, and nothing! Script stop in this moment. And You write this program in beter way than I expected, and I think "Specify Offset distance" could put into code (without puting it in Autocad). Could you correct this? Thank you. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 Is there any error message at the command line ? Are you sure that the distance you provide is not longer than the object's length ? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 Hope that someone could try the code and tell us about the result Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 12, 2014 Share Posted March 12, 2014 Hope that someone could try the code and tell us about the result Work on my end. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 Work on my end. Thank you Marek for your kind try Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 12, 2014 Share Posted March 12, 2014 No problem, any time. I don't have Camtasia, can you add eye under arc-will looks like blinking eye... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted March 12, 2014 Share Posted March 12, 2014 I don't have Camtasia, can you add eye under arc-will looks like blinking eye... What are you indicating to ? I did not get it Quote Link to comment Share on other sites More sharing options...
Wojciech Posted March 12, 2014 Author Share Posted March 12, 2014 There are no errors. Yes, I am sure. 1.5 I set as a default. Zoom is correct. Line eg. 100 lengh. Command: test Specify point at the End Side of Polyline : Specify Offset distance < 1.5 > : Command: ps. but on first time, it works... now it do not work in any file in Autocad.. Another LISP works corretly Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted March 12, 2014 Share Posted March 12, 2014 Ej, Wojtek cos namieszales... Tharwat, blinking eye.... Quote Link to comment Share on other sites More sharing options...
Wojciech Posted March 12, 2014 Author Share Posted March 12, 2014 Ok, ok, I know where is the problem.. In first start of the script, I cant click enter after "Specify Offset distance :" but I must put own number........ Tharwat, could you put "Specify Offset distance " to the code, without putting "Specify Offset distance " in the Autocad? This is not necessary now and it generating this problem. Greets Tharwat and pozdrowienia dla Marka Quote Link to comment Share on other sites More sharing options...
Guest Posted March 12, 2014 Share Posted March 12, 2014 I find in this site this lisp (defun C:SLOPE-LINE (/ Talud_boven Talud_onder afstand afstand_totaal count p1 p2 kleur) (defun IS-ON-PL? (ENAME PKT /) (vl-catch-all-apply 'vlax-curve-getdistatpoint (list ENAME PKT ) ;_ end of list ) ;_ end of vlax-curve-getDistAtPoint PKT ) ;_ end defun (vl-load-com) (if (and (setq Talud_boven (car (entsel "\nSelect top slope: "))) (setq Talud_onder (car (entsel "\nSelect bottom slope: "))) (setq afstand (getint "\nLine slope distance:")) (setq kleur (acad_colordlg ) ) ;_ end of and (progn (setq afstand_totaal 0) (setq count 0) (setq p1 (vlax-curve-getStartPoint (vlax-ename->vla-object Talud_boven) ) ;_ end of vlax-curve-getStartPoint ) ;_ end of setq (while p1 (if (equal (/ count 2.0) (fix (/ count 2.0)) 0.001) (setq p2 (vlax-curve-getClosestPointTo (vlax-ename->vla-object Talud_onder) p1 ) ;_ end of vlax-curve-getClosestPointTo ) ;_ end of setq (setq p2 (MAPCAR '(LAMBDA (x) (/ x 2)) (MAPCAR '+ p1 (vlax-curve-getClosestPointTo (vlax-ename->vla-object Talud_onder) p1 ) ;_ end of vlax-curve-getClosestPointTo ) ;_ end of MAPCAR ) ;_ end of MAPCAR ) ;_ end of setq ) ;_ end of if (entmake (list '(0 . "LINE") (cons 10 p1) (cons 11 p2) ;'(62 . 1) ; standaard kleur (cons 62 kleur) ; kleur dia dialog instellen ) ;_ end of list ) ;_ end of entmake (if (setq p1 (IS-ON-PL? (vlax-ename->vla-object Talud_boven) (vlax-curve-getpointatdist (vlax-ename->vla-object Talud_boven) (setq afstand_totaal (+ afstand_totaal afstand)) ) ;_ end of vlax-curve-getpointatdist ) ;_ end of IS-ON-PL? ) ;_ end of setq p1 ) ;_ end of if (setq count (1+ count)) ) ;_ end of while ) ;_ end of progn ) ;_ end of if ) ;_ end of defun Quote Link to comment Share on other sites More sharing options...
Wojciech Posted March 12, 2014 Author Share Posted March 12, 2014 (edited) I found a strange problem. The script on certain lines does not work. Command: test Specify point at the End Side of Polyline : Specify Offset distance < 1.5 > : Error: bad argument type: numberp: nil Command: Link to DWG: http://ftp.feniksg.unixstorm.org/wczyszczona_mapa.dwg Tharwat. When you try to fix the problem, please remove "Specify Offset distance" from command line - put it into code. Specify it into code like $variable = 1.5 edit: script not working with "lines"? Edited March 13, 2014 by Wojciech Quote Link to comment Share on other sites More sharing options...
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.