×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Autolisp code

Autolisp code

Autolisp code

(OP)
I have to make autolisp code with dialog box... It must be simple dialog box where i put filename and then press ok and program erase limited area? how to do?

RE: Autolisp code

To erase limited area:

please explain some more.
Should the file be opened first?
How should the limited area be defined?

If I know these, I can post a sample program that produces a dialog box for the purpose.


tigrek@hotpop.com
www.homescript.com

RE: Autolisp code

the autolisp function GETFILED will return a file name from within a dialog box ex.

(setq filename (getfiled "This Dialog Box" "This.fil" "fil" 8))

"This Dialog Box" is the dialog title, "This.fil" is the default file name to place in the edit box, "fil" is the extension to filter for, and 8 means to select name and it must exist. Check the online help for more on GETFILED.

To erase a specific area, simply assign two points defining upper right and lower left corners of a box to variables perhaps p1 and p2, then select everything in the area, then erase the selection set ex.

(setq selectionset(ssget "C" p1 p2))

Now you may either erase them one at a time or at once ex.

(command "_.erase" selectionset )
or
(setq ndx 0)
(repeat (sslength selectionset)
(entdel (ssname selectionset ndx))
(setq ndx (1+ ndx))
)

If you need to select objects in an irregular area set a list of points defining the perimeter of the area ex

(while (setq pt (getpoint))
 (if (not pointlist)
  (setq pointlist (list pt))
  (setq pointlist (append pointlist (list pt)))
 )
)
(setq selectionset (ssget "CP" pointlist))

To select only the entities completely contained within the selected area boundary, replace the C with W and the CP with WP in the ssget calls

Now you can create a small simple program:
(defun C:myprogram ( / pt pointlist ndx selectionset)
 (while (setq pt (getpoint "\nSelect defining point: "))
  (if (not pointlist)
   (setq pointlist (list pt))
   (setq pointlist (append pointlist (list pt)))
  )
 )
 (setq selectionset (ssget "CP" pointlist))
 (setq ndx 0)
 (repeat (sslength selectionset)
  (entdel (ssname selectionset ndx))
  (setq ndx (1+ ndx))
 )
)

Basically the above program is the same as if you typed erase at the keyboard then selected Crossing Polygon (CP).

Good luck

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources