Jump to content

Any function to draw Lines instead of Mline


Tharwat

Recommended Posts

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 :D

 

Many Thanks

Tharwat

Link to comment
Share on other sites

  • Replies 35
  • Created
  • Last Reply

Top Posters In This Topic

  • Tharwat

    11

  • alanjt

    9

  • Lee Mac

    8

  • The Buzzard

    4

Top Posters In This Topic

Posted Images

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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) 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

(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

Link to comment
Share on other sites

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.

 

Wall.gif

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 .................?:roll:

 

 

Tharwat

Link to comment
Share on other sites

Another :D

 

[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.

 

GrFun.gif

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...