Code Red > AutoLISP (Vanilla / Visual)

Continuous Polar Line with lisp

(1/2) > >>

siddik:
hi

i was digging the internet from couple of days to find our a lisp to draw an object with a continuous line, since my drawings are always symmetrical Circular Parts with n number of steps in Outer Diameter & inner Diameter, to draw a length is easy just line command & enter length, but to make steps diametrically i have to switch on transparent cal command & type (d1 - d2)/2 for each of the steps which is quite time consuming, & new users who are not use to cal command they use physical calculator for this process

can anybody help me with lisp code so that i just enter the length & next diameter until the last point, also need to generate a center line & mirror the object at the end & connect all the lines of inner diameter

hope my explanation is clear, even though i am attaching an example drawing for a clear picture.

d2010:

--- Code: ---TEXTSCR
REGEN
(COMMAND "UNITS" "2" "3" "3" "5" "300" "y")
(SETVAR "TEXTSIZE" 0.5)
(SETQ C1ECOLOR (GETVAR "CECOLOR"))
(SETQ C1LAYER (GETVAR "CLAYER"))
(IF (/= C1ECOLOR "1") (SETVAR "CECOLOR" "1"))
(IF (/= C1LAYER "0") (SETVAR "CLAYER" "0"))
(COMMAND "OSNAP" "OFF")
(COMMAND "_.UNDO" "_BEGIN")
TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @115.705<352.5315g
TEXT 3431.143,921.392   "pP1" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @86.318<388.878g
TEXT 3494.638,921.392   "pP2" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @71.591<386.5586g
TEXT 3494.638,906.390   "pP3" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @70.003<399.547g
TEXT 3509.144,906.390   "pP3" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @50.002<399.3657g
TEXT 3509.144,886.389   "pP5" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @70.003<399.547g
TEXT 3509.144,906.390   "pP4" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @50.002<399.3657g
TEXT 3509.144,886.389   "pP5" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @51.306<14.3931g
TEXT 3521.143,886.389   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @44.255<35.6378g
TEXT 3533.142,873.889   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @34.311<48.0318g
TEXT 3533.142,861.389   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @34.311<351.9682g
TEXT 3486.142,861.389   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @46.391<366.183g
TEXT 3486.142,876.387   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @60.58<345.9105g
TEXT 3464.144,876.387   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @71.38<356.0016g
TEXT 3464.144,891.389   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @60.58<345.9105g
TEXT 3464.144,876.387   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @71.38<356.0016g
TEXT 3464.144,891.389   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @86.295<343.9942g
TEXT 3443.146,891.389   "pP6" TEXT 3509.642,836.389   "s500"
LINE 3509.642,836.389 @100.235<353.8219g
TEXT 3443.146,911.390   "pP6"
(COMMAND "_.UNDO" "_END")
(COMMAND "OSNAP" "CEN")
(SETQ C1ECOLOR NIL)
(SETQ C1LAYER NIL)
GRAPHSCR

--- End code ---


--- Quote from: siddik on June 14, 2021, 07:59:35 AM ---i was digging the internet from couple of days to find our a lisp to draw an object with a continuous line, since my drawings are always symmetrical Circular Parts with n number of steps in Outer

--- End quote ---

BIGAL:
A lisp pick end of c/l go left or right, then make a list of the dia and step length, do a check before pressing ok a custom dcl. Then draw and as suggested mirror. This is very much like a stair.lsp.

If I get time will do something.

d2010 stop posting Bull@#$% where is the Administrator.

BIGAL:
I forgot about this may be a starting point. Could add maybe C for chamfer.


--- Code: ---; draw a pline by direction Up Down left or Right use upper or lowercase
; by Alan H dec 2015
; this version is a metric/decimal version
; version 2 depending on request will be a imperial version
; 1'8 1/4" input d1.8.25 start with 1.8 = 1'8" then add second fraction ver 3

; how to use u123.45 D34.57 R102.6

(defun ah:left ( / pt2)
(setq pt2 (polar pt pi (atof (substr ans 2 (- (strlen ans) 1)))))
(setq pt pt2)
(command pt2)
)

(defun ah:up ( / pt2)
(setq pt2 (polar pt (/ pi 2.0) (atof (substr ans 2 (- (strlen ans) 1)))))
(setq pt pt2)
(command pt2)
)

(defun ah:right ( / pt2)
(setq pt2 (polar pt 0.0 (atof (substr ans 2 (- (strlen ans) 1)))))
(setq pt pt2)
(command pt2)
)

(defun ah:down ( / pt2)
(setq pt2 (polar pt (* 1.5 pi) (atof (substr ans 2 (- (strlen ans) 1)))))
(setq pt pt2)
(command pt2)
)

(defun C:ahpliner ( / pt ans)

(command "_pline")
(command (setq pt (getpoint "Pick start point - Enter or C to finish")))
(while (= (getvar "cmdactive") 1 )
(setq ans (getstring "Enter L123 U456 R67 D78"))
(cond ((= ans "")(command ""))
      ((= "L"(strcase (substr ans 1 1)))(ah:left))
      ((= "U"(strcase (substr ans 1 1)))(ah:up))
      ((= "D"(strcase (substr ans 1 1)))(ah:down))
      ((= "R"(strcase (substr ans 1 1)))(ah:right))
      ((= "C"(strcase (substr ans 1 1)))(command "close"))
) ;cond
) ; while
)

--- End code ---

siddik:
thanks Bigal, we are almost there but need a little change in the code since this is only drawing Left, Right, Up & down, my requirement for down is to divide (d1-d2)/2, so if d1 is initially added with getreal and D should prompt for next Diameter(d2) and make the calculation as required will make the thing happen

Navigation

[0] Message Index

[#] Next page

Go to full version