Jump to content

Recommended Posts

Posted

Hey guys,

 

I'm working on a code but I am having issues with getting the DXF codes assigned to a variable and using the variables for the polygon command.

 

Basically what I am trying to do is to create a polygon that "traces" a circle that will help me with the wipeout command.

 

(defun c:test (/ obj)
 (setq obj (entsel"\nSelect Circle to Wipeout: "))
 (setq rad (assoc 40 obj))
 (setq cen (assoc 10 obj))
 (command
   "_.polygon" 50 cen "C" rad
   )
 )

 

I'm getting this error:

error: bad association list: (

7ffffb05b50> (3241.76 1416.18 0.0))

 

Any help is appreciated

Posted

perhaps something like this

 

(defun c:test (/ obj rad cen)
 (setq obj (entget (car (entsel "\nSelect Circle to Wipeout: "))))
 (setq rad (cdr (assoc 40 obj)))
 (setq cen (cdr (assoc 10 obj)))
 (command "_.polygon" 50 cen "_C" rad)
 (princ)
)

 

HTH

Henrique

Posted
perhaps something like this

 

(defun c:test (/ obj rad cen)
 (setq obj (entget (car (entsel "\nSelect Circle to Wipeout: "))))
 (setq rad (cdr (assoc 40 obj)))
 (setq cen (cdr (assoc 10 obj)))
 (command "_.polygon" 50 cen "_C" rad)
 (princ)
)

 

HTH

Henrique

 

Hi Henrique,

 

Thanks so much! That's what I was looking for!

 

I'm working now to add some error-checking to the program and I'm running into another error when I'm trying to test it in AutoCAD.

 

(defun c:test (/ obj rad cen wipeout)
 ;;this lisp will create a wipeout for a circle when selected by the user
 (if (setq obj (entget (car(entsel"\nSelect Circle to Wipeout: "))))
   (if (/= circle (cdr (assoc 0 obj)))
 (setq rad (cdr (assoc 40 obj)));;get radius from selection and set to "rad"
 (setq cen (cdr (assoc 10 obj)));;get center point from selection and set to "cen"
 (command
   "_.polygon" 50 cen "_C" rad
   )
 (setq poly (entlast));;set last entity to variable "poly"
 (command
   "_.wipeout" "_p" poly "_Y"
   )
 (setq wipeout (entlast));;set last entity to variable "wipeout"
 (command
   "_.draworder" wipeout "" "_b";;put wipeout behind object
   )
 (princ)
     (ALERT "YOU DIDN'T SELECT A CIRCLE")
     );;END 2ND IF
   (ALERT "YOU DIDN'T SELECT AN OBJECT")
   );;END 1ST IF
 )

 

I'm getting a too many arguments error

 

Maybe someone can give some insight for me in how to run error checking. One of my pet peeves is that when the if runs the nil value that it still continues the command. I'm trying to get it to skip to the end or to repeat back to the beginning.

 

Lee Mac: I will for sure look into that program.

 

Thanks!

Posted (edited)

You're welcome!

 

Try

 

(defun c:test (/ CEN ESEL OBJ POLY RAD WIPEOUT)
 ;;this lisp will create a wipeout for a circle when selected by the user
 (if (setq esel (entsel "\nSelect Circle to Wipeout: "));; get entity name and picked point
   (progn
     (if (and (setq obj (entget (car esel)));; get entity data
       (= "CIRCLE" (cdr (assoc 0 obj)));; test for "CIRCLE"
  );; and
(progn
  (setq rad (cdr (assoc 40 obj)));;get radius from selection and set to "rad"
  (setq cen (cdr (assoc 10 obj)));;get center point from selection and set to "cen"
  (command "_.polygon" 50 cen "_C" rad)
  (setq poly (entlast));;set last entity to variable "poly"
  (command "_.wipeout" "_p" poly "_Y")
  (setq wipeout (entlast));;set last entity to variable "wipeout"
  (command "_.draworder" wipeout "" "_b");;put wipeout behind object
);; progn
(ALERT "YOU DIDN'T SELECT A CIRCLE")
     );;END 2ND IF
   );; progn
   (ALERT "YOU DIDN'T SELECT AN OBJECT")
 );;END 1ST IF
 (princ)
);; test

 

HTH

Henrique

Edited by hmsilva
To declare some variables as local.
Posted

Thanks! That worked.

 

Thank you again Henrique.

Posted
Thanks! That worked.

 

Thank you again Henrique.

 

You're welcome, chiimayred

glad I could help

 

Henrique

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