Tharwat Posted June 18, 2010 Share Posted June 18, 2010 Hello, Is there any function or a method that could give the chance to draw tow lines as well as Mline continuously . Or maybe things like entmake ..... if possible please call Many Thanks Tharwat Quote Link to comment Share on other sites More sharing options...
TimSpangler Posted June 18, 2010 Share Posted June 18, 2010 I think this is what you are looking for. (defun DB_LINE (WallWidth / Point1 Point2 StartPt Start1 Start2 Line1 Line2 Line3 Line4 Int2 WallLayer WallLine) ;; Set the correct layer (setq WallLayer "0") (setq WallLine "BYLAYER") ;; Get first point (setq Point1 (getpoint "\n Define first point: ")) ;; Define first point as startpoint (setq StartPt Point1) ;; Get next point (setq Point2 (getpoint Point1 "\n Define next point: ")) ;; start to create the wall (setq Line1 (vlax-ename->vla-object (STDLIB_CREATE_LINE Point1 Point2 WallLayer WallLine 256))) ;; Defin the first line as the strting line (setq Start1 Line1) ;; Create second line (setq Line2 (car (vlax-invoke Line1 'offset WallWidth))) ;; Define the second line as the second start line (setq Start2 Line2) ;; Reset the first point to the second point (setq Point1 Point2) ;; While we are creating lines (while ;; Meet these criteria (progn ;; Watch to close (initget "Close") ;; get next point (setq Point2 (getpoint Point1 "\n Define next point: ")) ;; Check to see if it is a point list (= (type Point2) 'LIST) ) ;; Create next section of wall (setq Line3 (vlax-ename->vla-object (STDLIB_CREATE_LINE Point1 Point2 WallLayer WallLine 256))) (setq Line4 (car (vlax-invoke Line3 'offset WallWidth))) ;; Get the intersection of the first section and the second section (setq Int2 (vlax-invoke Line2 'intersectwith Line4 acExtendBoth)) ;; Chang the end points to meet (vlax-put Line2 'endpoint Int2) (vlax-put Line4 'startpoint Int2) ;; Reset the lines (setq Line1 Line3) (setq Line2 Line4) ;; Reset the point (setq Point1 Point2) ) ;; If the user want to close the line (if (= Point2 "Close") (progn ;; Create last section of wall (setq Line3 (vlax-ename->vla-object (STDLIB_CREATE_LINE Point1 StartPt WallLayer WallLine 256))) (setq Line4 (car (vlax-invoke Line3 'offset WallWidth))) ;; Get the intersection of the first section and the second section (setq Int2 (vlax-invoke Line2 'intersectwith Line4 acExtendBoth)) ;; Reset the lines (vlax-put Line2 'endpoint Int2) (vlax-put Line4 'startpoint Int2) ;; Now close it .... ;; Get the intersection of the last section and the first section (setq Int2 (vlax-invoke Start2 'intersectwith Line4 acExtendBoth)) ;; Chang the end points to meet (vlax-put Line4 'endpoint Int2) (vlax-put Start2 'startpoint Int2) ) ) ) ;;; ------------------------------------------------------------------------ ;;; STDLIB_CREATE_LINE.LSP ;;; ;;; Copyright © December, 2008 ;;; Timothy G. Spangler ;;; ;;; Permission to use, copy, modify, and distribute this software ;;; for any purpose and without fee is hereby granted, provided ;;; that the above copyright notice appears in all copies and ;;; that both that copyright notice and the limited warranty and ;;; restricted rights notice below appear in all supporting ;;; documentation. ;;; ;;; STDLIB_CREATE_LINE ;;; ;;; Description: ;;; Called from a menu pulldown or rightclick menu ;;; * (STDLIB_CREATE_LINE <STARTPOINT> <ENDPOINT> <LAYER> <LINETYPE> <COLOR> ) ;;; <STARTPOINT> = LIST = List of 2D / 3D points ;;; <ENDPOINT> = LIST = List of 2D / 3D points ;;; <LAYER> = STRING = Valid layer name ;;; <LINETYPE> = STRING = Valid linetype (loaded) ;;; <COLOR> = REAL = Valid color number ;;; ;;; Returns: ;;; Ename of created line ;;; ;;; ------------------------------------------------------------------------ ;;; MAIN FUNCTION ;;;;;;;;;;;;;;;;;;;;;;;;; (defun STDLIB_CREATE_LINE (StartPoint EndPoint Layer Linetype Color / LineList) (setq LineList (list (cons 0 "LINE") (cons 100 "AcDbEntity") (cons 100 "AcDbLine") (cons 6 Linetype) (cons 8 Layer) (cons 10 StartPoint) (cons 11 EndPoint) (cons 39 0.0) (cons 62 Color) (cons 210 (list 0.0 0.0 1.0)) ) ) (entmakex LineList) ) (princ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 18, 2010 Author Share Posted June 18, 2010 That's Great Mr.Tim I hope that I could handle these functions, And I think dealing with entmake would be a little bit eaiser to me. Do you have any Lisp that implementing entmake you provided in as an example. Thank you so much. Tharwat Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 18, 2010 Share Posted June 18, 2010 Heres Tims code with an added function to test. Load and type DB to start. (defun C:DB () (or WW (setq WW 4.0)) (setq WW$ (rtos WW 2 1)) (setq WW (cond ((getreaL (strcat "\nSpecify wall width: <"WW$">: ")))(T WW))) (DB_LINE WW) (princ)) (defun DB_LINE (WallWidth / Point1 Point2 StartPt Start1 Start2 Line1 Line2 Line3 Line4 Int2 WallLayer WallLine) ;; Set the correct layer (setq WallLayer "0") (setq WallLine "BYLAYER") ;; Get first point (setq Point1 (getpoint "\n Define first point: ")) ;; Define first point as startpoint (setq StartPt Point1) ;; Get next point (setq Point2 (getpoint Point1 "\n Define next point: ")) ;; start to create the wall (setq Line1 (vlax-ename->vla-object (STDLIB_CREATE_LINE Point1 Point2 WallLayer WallLine 256))) ;; Defin the first line as the strting line (setq Start1 Line1) ;; Create second line (setq Line2 (car (vlax-invoke Line1 'offset WallWidth))) ;; Define the second line as the second start line (setq Start2 Line2) ;; Reset the first point to the second point (setq Point1 Point2) ;; While we are creating lines (while ;; Meet these criteria (progn ;; Watch to close (initget "Close") ;; get next point (setq Point2 (getpoint Point1 "\n Define next point: ")) ;; Check to see if it is a point list (= (type Point2) 'LIST) ) ;; Create next section of wall (setq Line3 (vlax-ename->vla-object (STDLIB_CREATE_LINE Point1 Point2 WallLayer WallLine 256))) (setq Line4 (car (vlax-invoke Line3 'offset WallWidth))) ;; Get the intersection of the first section and the second section (setq Int2 (vlax-invoke Line2 'intersectwith Line4 acExtendBoth)) ;; Chang the end points to meet (vlax-put Line2 'endpoint Int2) (vlax-put Line4 'startpoint Int2) ;; Reset the lines (setq Line1 Line3) (setq Line2 Line4) ;; Reset the point (setq Point1 Point2) ) ;; If the user want to close the line (if (= Point2 "Close") (progn ;; Create last section of wall (setq Line3 (vlax-ename->vla-object (STDLIB_CREATE_LINE Point1 StartPt WallLayer WallLine 256))) (setq Line4 (car (vlax-invoke Line3 'offset WallWidth))) ;; Get the intersection of the first section and the second section (setq Int2 (vlax-invoke Line2 'intersectwith Line4 acExtendBoth)) ;; Reset the lines (vlax-put Line2 'endpoint Int2) (vlax-put Line4 'startpoint Int2) ;; Now close it .... ;; Get the intersection of the last section and the first section (setq Int2 (vlax-invoke Start2 'intersectwith Line4 acExtendBoth)) ;; Chang the end points to meet (vlax-put Line4 'endpoint Int2) (vlax-put Start2 'startpoint Int2) ) ) ) ;;; ------------------------------------------------------------------------ ;;; STDLIB_CREATE_LINE.LSP ;;; ;;; Copyright © December, 2008 ;;; Timothy G. Spangler ;;; ;;; Permission to use, copy, modify, and distribute this software ;;; for any purpose and without fee is hereby granted, provided ;;; that the above copyright notice appears in all copies and ;;; that both that copyright notice and the limited warranty and ;;; restricted rights notice below appear in all supporting ;;; documentation. ;;; ;;; STDLIB_CREATE_LINE ;;; ;;; Description: ;;; Called from a menu pulldown or rightclick menu ;;; * (STDLIB_CREATE_LINE <STARTPOINT> <ENDPOINT> <LAYER> <LINETYPE> <COLOR> ) ;;; <STARTPOINT> = LIST = List of 2D / 3D points ;;; <ENDPOINT> = LIST = List of 2D / 3D points ;;; <LAYER> = STRING = Valid layer name ;;; <LINETYPE> = STRING = Valid linetype (loaded) ;;; <COLOR> = REAL = Valid color number ;;; ;;; Returns: ;;; Ename of created line ;;; ;;; ------------------------------------------------------------------------ ;;; MAIN FUNCTION ;;;;;;;;;;;;;;;;;;;;;;;;; (defun STDLIB_CREATE_LINE (StartPoint EndPoint Layer Linetype Color / LineList) (setq LineList (list (cons 0 "LINE") (cons 100 "AcDbEntity") (cons 100 "AcDbLine") (cons 6 Linetype) (cons 8 Layer) (cons 10 StartPoint) (cons 11 EndPoint) (cons 39 0.0) (cons 62 Color) (cons 210 (list 0.0 0.0 1.0)) ) ) (entmakex LineList) ) (princ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 18, 2010 Author Share Posted June 18, 2010 Thank you Mr. Buzzard. I am so gald to hear from you once again, And that was very helpful. my beast regards, Tharwat Quote Link to comment Share on other sites More sharing options...
TimSpangler Posted June 18, 2010 Share Posted June 18, 2010 That's Great Mr.Tim I hope that I could handle these functions, And I think dealing with entmake would be a little bit eaiser to me. Do you have any Lisp that implementing entmake you provided in as an example. Thank you so much. Tharwat Here is the line in the code that calls the STDLIB_CREATE_LINE (STDLIB_CREATE_LINE Point1 Point2 WallLayer WallLine 256) Quote Link to comment Share on other sites More sharing options...
The Buzzard Posted June 18, 2010 Share Posted June 18, 2010 Thank you Mr. Buzzard. I am so gald to hear from you once again, And that was very helpful. my beast regards, Tharwat Just note that the argument WallWidth needs to be supplied with a value which in this case is WW. (defun C:DB () (or WW (setq WW 4.0)) (setq WW$ (rtos WW 2 1)) (setq WW (cond ((getreaL (strcat "\nSpecify wall width: <"WW$">: ")))(T WW))) (DB_LINE [color="Red"]WW[/color]) (princ)) (defun DB_LINE ([color="red"]WallWidth[/color] / Point1 Point2 StartPt Start1 Start2 Line1 Line2 Line3 Line4 Int2 WallLayer WallLine) This line calls the local function DB_LINE and the supplied argument is WW. (DB_LINE WW) Without a supplied value, You would get a too few arguments error. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 18, 2010 Author Share Posted June 18, 2010 Just note that the argument WallWidth needs to be supplied with a value which in this case is WW. (defun C:DB () (or WW (setq WW 4.0)) (setq WW$ (rtos WW 2 1)) (setq WW (cond ((getreaL (strcat "\nSpecify wall width: <"WW$">: ")))(T WW))) (DB_LINE [color="Red"]WW[/color]) (princ)) (defun DB_LINE ([color="red"]WallWidth[/color] / Point1 Point2 StartPt Start1 Start2 Line1 Line2 Line3 Line4 Int2 WallLayer WallLine) This line calls the local function DB_LINE and the supplied argument is WW. (DB_LINE WW) Fantastic. I have been trying this, but it's been disappointing me; (defun C:Dline () (setq pl (getpoint"\nSpecify first point:")) (DB_LINE) (princ)) Great indication to the heart of the issue from you. Hot regards, Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 18, 2010 Author Share Posted June 18, 2010 Here is the line in the code that calls the STDLIB_CREATE_LINE (STDLIB_CREATE_LINE Point1 Point2 WallLayer WallLine 256) Mr.Tim your help is highly appreciated. I couldn't get your point very well due to your short hint to it, and besides that, my medium level with Autolisp. Thanks agin and again ........ Tharwat Quote Link to comment Share on other sites More sharing options...
TimSpangler Posted June 18, 2010 Share Posted June 18, 2010 Fantastic.I have been trying this, but it's been disappointing me; (defun C:Dline () (setq pl (getpoint"\nSpecify first point:"))[color="Red"]<- you dont need this[/color] (DB_LINE)[color="red"]<- you will need to supply a real with this (DB_LINE 24.0)[/color] (princ)) Great indication to the heart of the issue from you. Hot regards, Tharwat Hope that helps you. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 18, 2010 Author Share Posted June 18, 2010 (defun C:Dline () (setq pl (getpoint"\nSpecify first point:")) (DB_LINE) (princ)) Hope that helps you. Now your point is clear to me, But to support a direct value that will tighten me strickly with no choice. So the suggestion of mr Buzzard was also helpful and flexible for all users.Plus saving the last value that user entered. (defun C:DB () (or WW (setq WW 4.0)) (setq WW$ (rtos WW 2 1)) (setq WW (cond ((getreaL (strcat "\nSpecify wall width: <"WW$">: ")))(T WW))) (DB_LINE WW) (princ)) (defun DB_LINE (WallWidth / Point1 Point2 StartPt Start1 Start2 Line1 Line2 Line3 Line4 Int2 WallLayer WallLine) A very great job from all. Tharwat Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 19, 2010 Share Posted June 19, 2010 I really liked this idea and decided to write my own. This will make drawing walls a piece of cake. I decided to have it draw either 2 LWPolylines or 1 closed LWPolyline. As you can see, the vectors drawn with grdraw use whatever color is set for the specified layer's properties. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 19, 2010 Author Share Posted June 19, 2010 Fantastic Alan, Soooooo Coooooooool. Why don't you share me that piece of cake ..? I am sure it is so delicious completely. I sure you do agree with me............... I will be waiting for a slice ........... Oki ? Best Regards. Tharwat Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 19, 2010 Author Share Posted June 19, 2010 Hi. Thats' what I have been looking for to draw HVAC Ducts, And also mr. Lee has his own one but that program is specialized in HVAC completely. and he said it's not free ware so I kept quiet . And what about you .................? Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 19, 2010 Share Posted June 19, 2010 Another Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 19, 2010 Author Share Posted June 19, 2010 Hi Lee. Thanks for the show. Tharwat Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 19, 2010 Share Posted June 19, 2010 Another [ATTACH]21028[/ATTACH][ATTACH]21029[/ATTACH] HaHa, that looks familiar. Looks nice. Sadly, you lose out on all normal functionality (OSnaps, etc.). Hell, the only reason I used GrRead for the following was because I was snapping to objects I selected. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 19, 2010 Share Posted June 19, 2010 HaHa, that looks familiar. No it doesn't, its nothing like your code. Sadly, you lose out on all normal functionality (OSnaps, etc.) No you don't, I haven't used grread. Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 19, 2010 Share Posted June 19, 2010 No Grread used... Alexander's GrRead replacement? Can't remember the name or find the link. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted June 19, 2010 Share Posted June 19, 2010 Alexander's GrRead replacement? Can't remember the name or find the link. Nope........ 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.