Bhanson Posted December 22, 2010 Posted December 22, 2010 I have some old CNC cut files in autocad that I need to update to an improved design, but I need to be able to delete objects in the drawing based on a typed input from the user (I cannot simply use the cursor to select the point). I have been trying to get this code to work and I just can't figure it out. Any ideas on how to make this work or how to improve my code? I also need to use a similar format using the stretch command shown below. (defun C:OCNCU ( ) ; Old CNC Update (setq len (getdist "Enter Cover Length = ")); Cover Length User Input (setq ptX (- len 0.25)) (command ".erase" (ssget "_C" '(0.25 25.0) '(ptx 26.0) "") ; Erase Extra Lines (setq SX (rtos 0.0) SY (rtos (/ len 20))) (command ".stretch" (ssget "_C" '(70.0 38.0) '(ptx 41.0)) "" "0,0" (strcat SX "," SY)) (command "zoom" "e") ); end of OCNCU Thanks in advance for your help! Quote
David Bethel Posted December 22, 2010 Posted December 22, 2010 Welcome to the forum! First off try: (list stx 36.0) & (list ptx 41.0) Secondly, if you are trying add nnn units to the X axis of a selection set, then I would try to modify the entities rather than trying to use the quirky STRECTH command. Do you a have dwg that you can post? -David Quote
alanjt Posted December 22, 2010 Posted December 22, 2010 Stretch is a great command, but impossible to function properly with command. You're just better off doing all the dirty work. Quote
CALCAD Posted December 22, 2010 Posted December 22, 2010 Bhanson, I worked on your code a little. It executes, though I'm not sure it's doing what you want. And while the STRETCH command seems to complete, it may be doing strange things as Dave and Alan warned. (defun C:OCNCU ( ) ; Old CNC Update (setq len (getdist "Enter Cover Length = ")); Cover Length User Input (setq ptx (- len 0.25)) ;(command ".delete" (ssget "C" '(0.25 25.0) '(ptx 26.0)) "") ; Erase Extra Lines (command ".delete" (ssget "C" (list 0.25 0.25) (list ptx 26.0)) "") ; added close parens ;(setq SX (rtos 0.0) SY (rtos (/ len 20))) (setq SX 0.0 SY (/ len 20)) ; must be reals - can't be strings ;(command ".stretch" (ssget "C" (list 9.1 0.25) (list ptx 41.0)) "" (list 0 0) "" (list SX SY)) (command ".stretch" (list 9.1 0.25) (list ptx 41.0) "" (list 0 0) (list SX SY)) ; give it discrete points instead of SS (command "zoom" "e") ); end of OCNCU Quote
Bhanson Posted December 22, 2010 Author Posted December 22, 2010 It works!!!!!!! Thank You for all of your help. I could not use the ".delete" command because my autocad didn't recognize it for some reason, but I was able to get the ".erase" command to work just the same as I think you intended. I will work on the stretch function and see how it works and let you know. I have used stretch quite often and works well for me so I'll see how it goes. (setq len 101.25) ;(setq len (getdist "Enter Cover Length = ")); Cover Length User Input ;I commented this part out for testing purposes (setq ptx (- len 0.25)) (command ".erase" (ssget "C" (list 0.25 25.0) (list ptx 26.0)) "") Thanks Again Here is an images of the file I am editing. The reason for needing the variable input is to vary the deleted line selection based on the cut file dimensions. Quote
Bhanson Posted December 22, 2010 Author Posted December 22, 2010 Here is the full completed code using .erase and .stretch commands short and effective! (setq len 101.25) (setq Width 73.25) ;(setq len (getdist "Enter Cover Length: ")); Cover Length User Input (omitted for testing) ;(setq Width (getdist "Enter Cover Width: ")); Cover Width User Input (omitted for testing) ; Erase Selection (setq ptx (- len 0.25)) (command ".erase" (ssget "C" (list 0.25 25.0) (list ptx 26.0)) "") ; Stretch Selection (setq pty (- Width 10.0)) (setq SX (rtos 0.5) SY (rtos 0.0)); this sets how far the selection will be stretched (command ".stretch" (ssget "_C" (list 0.6 10.0) (list 5.0 pty)) "" "0,0" (strcat SX "," SY)) ; as you can see the crossing window selection from (0.6,10.0) to (5.0 (Width - 10)) is stretched the distance from point (0,0) to (0.5, 0,0) in the x direction using the (strcat SX "," SY) part of the code. (princ) Thanks Again! Quote
CALCAD Posted December 23, 2010 Posted December 23, 2010 I had forgotten I switched ERASE to DELETE. On my Intellicad, DELETE is the command name and ERASE is an alias. Anyway, you sorted it out. I'm glad it's working for you. Quote
Recommended Posts
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.