Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autolisp code

Status
Not open for further replies.

Guest
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?
 
Replies continue below

Recommended for you

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
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor