Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Draw polyline arc circuits. It essential for electrical and lighting design.

26 REPLIES 26
SOLVED
Reply
Message 1 of 27
robertas_suminskas2
5659 Views, 26 Replies

Draw polyline arc circuits. It essential for electrical and lighting design.

robertas_suminskas2
Enthusiast
Enthusiast

It seems that AutoCAD dev team doesn't have a clue what software they are making and who is suppose to use. I don't need tools which consume a lot of time and it makes inaccurate and is not presentable to the client. We are not in Paper age anymore.

I am looking for a simple lisp or tool to draw polyline arc circuits with a defined angle and only two-point. Then it should work is like what. First I set angle that always will 30 (that I mean by 30. It doesn't matter if I will go up, or down, or any direction it will always will make the same angle between to point) and then I start First Point, then Next point. And when Next point. So basically you start with setting angle 30, when you chose the first point, when you chose the next point, after that always next point until you decide to change the angle.

I tried AutoCAD 2021 polylines, it draws snakes or you have always type angle and also calculate angle if you go up or down or any direction and so on.

I tried AutoCAD MEP 2021 using wire objects which are crap function. You still have to chose three points.

Can some help me in this situation as Autodesk team failed to make useful and simple tools for Electrical and Lighting design.

 

Many thanks,

 

Robertas

0 Likes

Draw polyline arc circuits. It essential for electrical and lighting design.

It seems that AutoCAD dev team doesn't have a clue what software they are making and who is suppose to use. I don't need tools which consume a lot of time and it makes inaccurate and is not presentable to the client. We are not in Paper age anymore.

I am looking for a simple lisp or tool to draw polyline arc circuits with a defined angle and only two-point. Then it should work is like what. First I set angle that always will 30 (that I mean by 30. It doesn't matter if I will go up, or down, or any direction it will always will make the same angle between to point) and then I start First Point, then Next point. And when Next point. So basically you start with setting angle 30, when you chose the first point, when you chose the next point, after that always next point until you decide to change the angle.

I tried AutoCAD 2021 polylines, it draws snakes or you have always type angle and also calculate angle if you go up or down or any direction and so on.

I tried AutoCAD MEP 2021 using wire objects which are crap function. You still have to chose three points.

Can some help me in this situation as Autodesk team failed to make useful and simple tools for Electrical and Lighting design.

 

Many thanks,

 

Robertas

Labels (3)
26 REPLIES 26
Message 2 of 27

Moshe-A
Mentor
Mentor

@robertas_suminskas2 

 

You do not need any lisp to do that, AutoCAD is loaded with this feature since it bord.

 

explore SNAP command & Rotate option

have you heard about ORTHO?

 

Moshe

 

0 Likes

@robertas_suminskas2 

 

You do not need any lisp to do that, AutoCAD is loaded with this feature since it bord.

 

explore SNAP command & Rotate option

have you heard about ORTHO?

 

Moshe

 

Message 3 of 27

robertas_suminskas2
Enthusiast
Enthusiast

Moshe,

 

I think you misunderstand. I have a picture as an example. Please see See highlighted examples. This is one polyline.

 

See highlighted examplesSee highlighted examples

 

Regards,

 

Robertas

0 Likes

Moshe,

 

I think you misunderstand. I have a picture as an example. Please see See highlighted examples. This is one polyline.

 

See highlighted examplesSee highlighted examples

 

Regards,

 

Robertas

Message 4 of 27

Moshe-A
Mentor
Mentor

i'm sorry i do not see any relation between your request and the picture

where is the 30 degree angle here?

 

 

0 Likes

i'm sorry i do not see any relation between your request and the picture

where is the 30 degree angle here?

 

 

Message 5 of 27

ВeekeeCZ
Consultant
Consultant

Try this. The only issue is that you have to end it by ESC, twice. At this point can't figure out better way... 

 

(defun c:PLA nil
  (command "_.pline" pause "_arc")
  (while (> (getvar 'CMDACTIVE) 0)
    (command "_angle" 30 pause))
  (princ)
  )

 

Try this. The only issue is that you have to end it by ESC, twice. At this point can't figure out better way... 

 

(defun c:PLA nil
  (command "_.pline" pause "_arc")
  (while (> (getvar 'CMDACTIVE) 0)
    (command "_angle" 30 pause))
  (princ)
  )

 

Message 6 of 27

Kent1Cooper
Consultant
Consultant

See >this<.

Kent Cooper, AIA
0 Likes

See >this<.

Kent Cooper, AIA
Message 7 of 27

robertas_suminskas2
Enthusiast
Enthusiast

 

AutoCAD Forum 2.png

0 Likes

 

AutoCAD Forum 2.png

Message 8 of 27

devitg
Advisor
Advisor

@robertas_suminskas2 For better understanding, and maybe get further help, please upload such sample.dwg

0 Likes

@robertas_suminskas2 For better understanding, and maybe get further help, please upload such sample.dwg

Message 9 of 27

robertas_suminskas2
Enthusiast
Enthusiast

It can be challenging but at some time it is very useful to have a lisp or tools to make circuits or logical groups for lighting. 

 

Please see the attached example.

0 Likes

It can be challenging but at some time it is very useful to have a lisp or tools to make circuits or logical groups for lighting. 

 

Please see the attached example.

Message 10 of 27

ВeekeeCZ
Consultant
Consultant

The previous code is impossible to impove.

The following is a different approach. 

 

(defun c:PLA ( / *error* e q p a o done)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if e (setvar 'cmdecho e))
    (princ))
  
  ; ------------------------------------------------------------------------------------------------------------
  
  (setq e (getvar 'cmdecho)) (setvar 'cmdecho 0)
  (princ "Specify first point: ")
  (command "_.pline" pause "_arc")
  (setq p (getvar 'lastpoint)
	a 1)
  (while (not done)
    (initget "Done Undo Lastswap")
    (setq o (getpoint p (strcat "\r>> Next " (if (minusp a) "LEFT" "RIGHT") " curve point or [Undo/Lastswap/Done] : ")))
    (cond ((not o)		(setq a (* a -1)))
	  ((= o "Undo")		(if q (setq p q)) (command "_undo" "_arc"))
	  ((= o "Done")		(setq done (vl-cmdf "")))
	  ((= o "Lastswap")	(command "_undo" "_arc" "_angle" (* (setq a (* a -1)) 30) "_non" p))
	  (T			(command "_angle" (* a 30) "_non" (setq q p p o)))))
  (princ)
  )

 

The previous code is impossible to impove.

The following is a different approach. 

 

(defun c:PLA ( / *error* e q p a o done)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if e (setvar 'cmdecho e))
    (princ))
  
  ; ------------------------------------------------------------------------------------------------------------
  
  (setq e (getvar 'cmdecho)) (setvar 'cmdecho 0)
  (princ "Specify first point: ")
  (command "_.pline" pause "_arc")
  (setq p (getvar 'lastpoint)
	a 1)
  (while (not done)
    (initget "Done Undo Lastswap")
    (setq o (getpoint p (strcat "\r>> Next " (if (minusp a) "LEFT" "RIGHT") " curve point or [Undo/Lastswap/Done] : ")))
    (cond ((not o)		(setq a (* a -1)))
	  ((= o "Undo")		(if q (setq p q)) (command "_undo" "_arc"))
	  ((= o "Done")		(setq done (vl-cmdf "")))
	  ((= o "Lastswap")	(command "_undo" "_arc" "_angle" (* (setq a (* a -1)) 30) "_non" p))
	  (T			(command "_angle" (* a 30) "_non" (setq q p p o)))))
  (princ)
  )

 

Message 11 of 27

robertas_suminskas2
Enthusiast
Enthusiast

Thank you for the code. I am trying to figure out how do you flip arc to the opposite side with the same angle? When I pres L it brings back standard polyline commands.

0 Likes

Thank you for the code. I am trying to figure out how do you flip arc to the opposite side with the same angle? When I pres L it brings back standard polyline commands.

Message 12 of 27

ВeekeeCZ
Consultant
Consultant

Oops, <flip> option was removed by this site :(.

While fixing - I renamed Done to Exit and swap to flip.

 

<flip> be applied for next arc and stays that way

<lastflip> flips the last one and stays that way, this basically combines undo+flip+last point

<undo> <exit> are obvious.

 

(defun c:PLA ( / *error* e q p a o done)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if e (setvar 'cmdecho e))
    (princ))
  
  ; ------------------------------------------------------------------------------------------------------------
  
  (setq e (getvar 'cmdecho)) (setvar 'cmdecho 0)
  (princ "Specify first point: ")
  (command "_.pline" pause "_arc")
  (setq p (getvar 'lastpoint)
	a 1)
  (while (not done)
    (initget "Exit Undo flipLast")
    (setq o (getpoint p (strcat "\r>> Next " (if (minusp a) "LEFT" "RIGHT") " curve point or [flipLast/Undo/Exit] <flip>: ")))
    (cond ((not o)		(setq a (* a -1)))
	  ((= o "Undo")		(if q (setq p q)) (command "_undo" "_arc"))
	  ((= o "Exit")		(setq done (vl-cmdf "")))
	  ((= o "flipLast")	(command "_undo" "_arc" "_angle" (* (setq a (* a -1)) 30) "_non" p))
	  (T			(command "_angle" (* a 30) "_non" (setq q p p o)))))
  (princ)
  )
<>

 

 

Oops, <flip> option was removed by this site :(.

While fixing - I renamed Done to Exit and swap to flip.

 

<flip> be applied for next arc and stays that way

<lastflip> flips the last one and stays that way, this basically combines undo+flip+last point

<undo> <exit> are obvious.

 

(defun c:PLA ( / *error* e q p a o done)
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if e (setvar 'cmdecho e))
    (princ))
  
  ; ------------------------------------------------------------------------------------------------------------
  
  (setq e (getvar 'cmdecho)) (setvar 'cmdecho 0)
  (princ "Specify first point: ")
  (command "_.pline" pause "_arc")
  (setq p (getvar 'lastpoint)
	a 1)
  (while (not done)
    (initget "Exit Undo flipLast")
    (setq o (getpoint p (strcat "\r>> Next " (if (minusp a) "LEFT" "RIGHT") " curve point or [flipLast/Undo/Exit] <flip>: ")))
    (cond ((not o)		(setq a (* a -1)))
	  ((= o "Undo")		(if q (setq p q)) (command "_undo" "_arc"))
	  ((= o "Exit")		(setq done (vl-cmdf "")))
	  ((= o "flipLast")	(command "_undo" "_arc" "_angle" (* (setq a (* a -1)) 30) "_non" p))
	  (T			(command "_angle" (* a 30) "_non" (setq q p p o)))))
  (princ)
  )
<>

 

 
Message 13 of 27

robertas_suminskas2
Enthusiast
Enthusiast

Wow, it is impressive. Thank you so much. Is it a lot of work to add to the code an input where you set angle. And also you can change the angle at any time?

0 Likes

Wow, it is impressive. Thank you so much. Is it a lot of work to add to the code an input where you set angle. And also you can change the angle at any time?

Message 14 of 27

ВeekeeCZ
Consultant
Consultant
Accepted solution

Ok, here's an update. 

Besides an angle setting also fixed multiple Undo and Exit by X or + keys.

 

(defun c:PLA ( / *error* e u p d o done)

  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if u (setvar 'aunits u))
    (if e (setvar 'cmdecho e))
    (princ))
  
  ; ------------------------------------------------------------------------------------------------------------
  
  (or *pla-a* (setq *pla-a* 30.))

  (setq e (getvar 'cmdecho)) (setvar 'cmdecho 0)
  (setq u (getvar 'aunits))  (setvar 'aunits 0)
  
  (princ "Specify first point: ")
  (command "_.pline" pause "_arc")
  (setq p (list (getvar 'lastpoint))
	d 1)
  (while (not done)
    (initget "Angle Exit Undo flipLast X +")
    (setq o (getpoint (car p) (strcat "\nCurrent angle: " (rtos *pla-a*)
				      "\n>> Next " (if (minusp (* d *pla-a*)) "LEFT" "RIGHT") " curve point or [Angle/flipLast/Undo/Exit] <flip>: ")))
    (cond ((not o)		(setq d (* d -1)))

	  ((= o "Angle")	(initget 1) (setq *pla-a* (getreal (strcat "\nCurrent angle: " (rtos *pla-a*)  "\nSpeficy new angle: "))))
	  ((= o "Undo")		(if (= 1 (length p))
				  (princ "\nError: Can't undo last point.")
				  (progn (setq p (cdr p)) (command "_undo" "_arc"))))
	  ((vl-position o '("Exit" "X" "+"))	(setq done (vl-cmdf "")))
	  ((= o "flipLast")	(command "_undo" "_arc" "_angle" (* (setq d (* d -1)) *pla-a*) "_non" (car p)))
	  (T			(command "_angle" (* d *pla-a*) "_non" (car (setq p (cons o p)))))))
  (princ)
  )

 

 

Ok, here's an update. 

Besides an angle setting also fixed multiple Undo and Exit by X or + keys.

 

(defun c:PLA ( / *error* e u p d o done)

  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if u (setvar 'aunits u))
    (if e (setvar 'cmdecho e))
    (princ))
  
  ; ------------------------------------------------------------------------------------------------------------
  
  (or *pla-a* (setq *pla-a* 30.))

  (setq e (getvar 'cmdecho)) (setvar 'cmdecho 0)
  (setq u (getvar 'aunits))  (setvar 'aunits 0)
  
  (princ "Specify first point: ")
  (command "_.pline" pause "_arc")
  (setq p (list (getvar 'lastpoint))
	d 1)
  (while (not done)
    (initget "Angle Exit Undo flipLast X +")
    (setq o (getpoint (car p) (strcat "\nCurrent angle: " (rtos *pla-a*)
				      "\n>> Next " (if (minusp (* d *pla-a*)) "LEFT" "RIGHT") " curve point or [Angle/flipLast/Undo/Exit] <flip>: ")))
    (cond ((not o)		(setq d (* d -1)))

	  ((= o "Angle")	(initget 1) (setq *pla-a* (getreal (strcat "\nCurrent angle: " (rtos *pla-a*)  "\nSpeficy new angle: "))))
	  ((= o "Undo")		(if (= 1 (length p))
				  (princ "\nError: Can't undo last point.")
				  (progn (setq p (cdr p)) (command "_undo" "_arc"))))
	  ((vl-position o '("Exit" "X" "+"))	(setq done (vl-cmdf "")))
	  ((= o "flipLast")	(command "_undo" "_arc" "_angle" (* (setq d (* d -1)) *pla-a*) "_non" (car p)))
	  (T			(command "_angle" (* d *pla-a*) "_non" (car (setq p (cons o p)))))))
  (princ)
  )

 

 
Message 15 of 27
pbejse
in reply to: ВeekeeCZ

pbejse
Mentor
Mentor

@ВeekeeCZ wrote:

Ok, here's an update. 

Besides an angle setting also fixed multiple Undo and Exit by X or + keys.

 

(defun c:PLA ( / *error* e u p d o done)
....(command "_angle" (* d *pla-a*) "_non" (car (setq p (cons o p)))))))
  (princ)
  )

 

 

Very nice @ВeekeeCZ  👍

 


@ВeekeeCZ wrote:

Ok, here's an update. 

Besides an angle setting also fixed multiple Undo and Exit by X or + keys.

 

(defun c:PLA ( / *error* e u p d o done)
....(command "_angle" (* d *pla-a*) "_non" (car (setq p (cons o p)))))))
  (princ)
  )

 

 

Very nice @ВeekeeCZ  👍

 

Message 16 of 27

robertas_suminskas2
Enthusiast
Enthusiast

Thank you so much. This is exactly that I needed. It is so efficient and now I can make client friendly design without taking so much time.

 

Thank you again.

0 Likes

Thank you so much. This is exactly that I needed. It is so efficient and now I can make client friendly design without taking so much time.

 

Thank you again.

Message 17 of 27

stevor
Collaborator
Collaborator

Then use 3 points to define the arc,

with the middle pt to select which side to turn the arc,

not necessarily on the arc.

Easier to make the pline from those arcs than by a continuous create.

S
0 Likes

Then use 3 points to define the arc,

with the middle pt to select which side to turn the arc,

not necessarily on the arc.

Easier to make the pline from those arcs than by a continuous create.

S
Message 18 of 27

robertas_suminskas2
Enthusiast
Enthusiast

That you propose is for time wasters and second, you must align middle point to make it the same unless you do approximately. Also, that is quicker do with two-click or three clicks? I don't really appreciate people who do job randomly pasting distances or objects. I appreciate people who draw lines, draw objects with meaning and accuracy without wasting time and making drawing perfect.

0 Likes

That you propose is for time wasters and second, you must align middle point to make it the same unless you do approximately. Also, that is quicker do with two-click or three clicks? I don't really appreciate people who do job randomly pasting distances or objects. I appreciate people who draw lines, draw objects with meaning and accuracy without wasting time and making drawing perfect.

Message 19 of 27

ВeekeeCZ
Consultant
Consultant

@robertas_suminskas2 

Glad to help. Hope your clients will appreciate it.

 

And thx @pbejse !

0 Likes

@robertas_suminskas2 

Glad to help. Hope your clients will appreciate it.

 

And thx @pbejse !

Message 20 of 27

ronjonp
Advisor
Advisor

@robertas_suminskas2 

Just for my education, why are all your light? block names unique? Kinda defeats the purpose of having a block.

image.png

0 Likes

@robertas_suminskas2 

Just for my education, why are all your light? block names unique? Kinda defeats the purpose of having a block.

image.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report