Jump to content

Help with this routine


jcap91163

Recommended Posts

A very long time ago, I encounter a routine called Detail, the main function is to create a circle with a variable diameter, it creates the circle and all the elements inside the circle are copied then prompt to move the circle to other place in the drawing and then asks for a scale value, this is great to take elements of one drawing and places in other side with other scale to indicate a detail.

Unfortunately the routine only works once, and after this, when ask me for a circle radius, the routine wont work anymore, copying only the elements with any luck.

I put the routine for your valuable help, in advance, many thanks.

 

(defun dtr (a)

(* pi (/ a 180.00))

)

;________________________________________________________________________

(defun P_circle ( ang1 ang pt)

(repeat n

(setq new_ang (+ ang1 ang))

(setq ang1 new_ang)

(setq new_pt (polar pt new_ang rad))

(setq pt_list (append pt_list (list new_pt)))

)

)

;________________________________________________________________________

(defun C:detail (/ pt_list a)

(setvar "cmdecho" 0)

(setq ltsc (getvar "ltscale"))

(command "ltscale" 0.05)

(command "regen")

(setq n 45)

(setq pt (getpoint "\ncenter point: "))

(prompt "\nEnter Radius: ")

(command "circle" pt pause)

(setq prop1 (entget (entlast))

rad (cdr (assoc 40 prop1))

ang (dtr 8)

ang1 0

pt1 (polar pt ang1 rad))

(setq ent1 (entlast))

(p_circle ang1 ang pt)

(prompt "\nSecond Point of Displacement: ")

(command "copy" "cp" pt1 (foreach p Pt_list (command p) "") "" pt pause)

(setq pt_list nil)

 

(setq pt (getvar "lastpoint")

ang1 0

ang (dtr 8)

pt1 (polar pt ang1 rad))

(p_circle ang1 ang pt)

(command "move" "cp" pt1 (foreach p Pt_list (command p)"") "" pt1 pt1)

(setq rad (+ rad (* 0.05 (getvar "dimscale")))

ang1 0

ang (dtr 12)

n 30

pt1 (polar pt ang1 rad)

pt_list nil)

(p_circle ang1 ang pt)

 

(command "trim" "p" "" "f" pt1 (foreach p pt_list (command p) "") "")

 

(setq pt_list nil

sf (getreal "\nEnter scale Factor:"))

(if (or(= sf nil)(= sf ""))(setq sf 1))

(command "scale" "p" "" pt sf)

(command "text" (getvar "viewctr") (* 0.18 sf) "" (strcat "Scale Factor " (rtos sf 2 1) "x"))

(prompt "\nSnap Text to point: ")

(command "move" (entlast) "" (getvar "viewctr") pause)

(command "erase" ent1 "")

(setvar "ltscale" ltsc)

(command "regen")

(princ)

)

Link to comment
Share on other sites

Small mistakes found as the following ...

(defun dtr (a)
(* pi (/ a 180.00))
)
;_________________________________________________ _______________________
(defun P_circle ( ang1 ang pt)
(repeat n
(setq new_ang (+ ang1 ang))
(setq ang1 new_ang)
(setq new_pt (polar pt new_ang rad))
(setq pt_list (append pt_list (list new_pt)))
)
)
;_________________________________________________ _______________________
(defun C:detail (/ pt_list a)
(setvar "cmdecho" 0)
(setq ltsc (getvar "ltscale"))
(command "ltscale" 0.05)
(command "regen")
(setq n 45)
(setq pt (getpoint "\ncenter point: "))
(prompt "\nEnter Radius: ")
(command "circle" pt pause)
(setq prop1 (entget (entlast))
     rad (cdr (assoc 40 prop1))
     ang (dtr 
     ang1 0
pt1 (polar pt ang1 rad))
[color="red"](setq ent1 (entlast))[/color]
(p_circle ang1 ang pt)
(prompt "\nSecond Point of Displacement: ")
(command "copy" "cp" pt1 (foreach p Pt_list (command p) "") "" pt pause) 
(setq pt_list nil) 

(setq pt (getvar "lastpoint")
     ang1 0
     ang (dtr 
     pt1 (polar pt ang1 rad))[color="red"])[/color]
(p_circle ang1 ang pt)
(command "move" "cp" pt1 (foreach p Pt_list (command p)"") "" pt1 pt1)
(setq rad (+ rad (* 0.05 (getvar "dimscale")))
ang1 0
ang (dtr 12)
n 30
pt1 (polar pt ang1 rad)
pt_list nil)
(p_circle ang1 ang pt)

(command "trim" "p" "" "f" pt1 (foreach p pt_list (command p) "") "")

(setq pt_list nil
sf (getreal "\nEnter scale Factor:"))
(if (or(= sf nil)(= sf ""))(setq sf 1))
(command "scale" "p" "" pt sf)
(command "text" (getvar "viewctr") (* 0.18 sf) "" (strcat "Scale Factor " (rtos sf 2 1) "x"))
(prompt "\nSnap Text to point: ")
(command "move" (entlast) "" (getvar "viewctr") pause)
(command "erase" ent1 "")
(setvar "ltscale" ltsc)
(command "regen")
(princ)
)[color="red"])[/color]

 

And for entlast I think it should be followed after an action of command like Circle, Line, Pline.......

 

so you will get it by entlast, So that's why it give an error in your codes.

 

Regards

Link to comment
Share on other sites

I'm afraid to say, that it wont work anymore, in the command line after opening autocad, shows a syntax error and when I load the routine, shows that the command doesn't exists

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