Baber62 Posted October 19, 2012 Posted October 19, 2012 I was wondering whether there is a method in lisp to turn the offset/erase command to yes. This deletes the orignal line from which it is is offset. Then when exiting the lisp routine to revert back to offset/erase command to no. So the next time you use the offset command it doesn't delete the original line. So far as the theories of mathematics are about reality, they are not certain; so far as they are certain, they are not about reality. Albert Einstein. Quote
nod684 Posted October 19, 2012 Posted October 19, 2012 I was wondering whether there is a method in lisp to turn the offset/erase command to yes. This deletes the orignal line from which it is is offset. Then when exiting the lisp routine to revert back to offset/erase command to no. So the next time you use the offset command it doesn't delete the original line. try this one : (defun c:OFF (/ offset_dist obj_2_offset offset_side) (setq old_osm (getvar 'OSMODE)) (setvar 'osmode 0) (setvar 'cmdecho 0) (while (= offset_dist nil) (setq offset_dist (getdist "\nOffset distance: ")) );while (while (= obj_2_offset nil) (setq obj_2_offset (entsel (strcat "\nPick object to offset <" (rtos offset_dist) ">: "))) );while (while (= offset_side nil) (setq offset_side (getpoint "\nSide to offset on: ")) );while (command "offset" offset_dist obj_2_offset offset_side "") (command "erase" obj_2_offset "") (setq obj_2_offset nil) (setq offset_side nil) (setvar "osmode" 14527) (princ)) Quote
Baber62 Posted October 19, 2012 Author Posted October 19, 2012 Hi Nod, Please can you let me know where in the lisp coding it returns the offset command to not erase the line. I am a newbie to lisp and would appreciate some comments in the coding if that's not too much bother. So far as the theories of mathematics are about reality, they are not certain; so far as they are certain, they are not about reality. Albert Einstein. Quote
Tharwat Posted October 19, 2012 Posted October 19, 2012 @NOD You have assigned the osmode to a variable and you did not reset it back as it was before and besides that , you kept it global and set the osmode to another value . You set the osmode off before the function getdist which would prevent the user to get a distance between two specific points ( if a user wanted so ) . Finally , What would happen if the user pressed esc button before getting the distance or before ending the routine ? Thanks Quote
Baber62 Posted October 20, 2012 Author Posted October 20, 2012 @THARWAT I was thinking along the same lines ... NOD has not reset the set variables back to old_osm. Anyone have any further ideas on this. So far as the theories of mathematics are about reality, they are not certain; so far as they are certain, they are not about reality. Albert Einstein. Quote
Tharwat Posted October 20, 2012 Posted October 20, 2012 Is this what you are after ? ...... (defun c:Off (/ del p s) ;;; Tharwat 20. Oct. 2012 ;;; (if (and (setq *dis* (cond ((getdist (strcat "\n Specify Offset Distance <" (if *dis* (rtos *dis* 2 2) (setq *dis* (rtos 1.0 2 2)) ) " > :" ) ) ) (t *dis*) ) ) (progn (initget "Yes No") (setq del (cond ((getkword "\n Delete original object [Yes/No] <Yes> :") ) ("Yes") ) ) ) ) (while (and (setq s (ssget "_+.:S:L" '((0 . "*LINE,CIRCLE,ELLIPSE")))) (setq p (getpoint "\n Specify point on side to offset :")) ) (vl-cmdf "_.offset" "_E" del *dis* (ssname s 0) "_non" p "") ) (princ) ) (princ) ) Quote
nod684 Posted October 22, 2012 Posted October 22, 2012 oopps sorry bout that! coz our system keeps on resetting to osmode 0 that is why i didnt reset the osmode. forgot to edit before posting. thanks tharwat! Quote
Baber62 Posted October 22, 2012 Author Posted October 22, 2012 Tharwat, I have tried your routine, it doesn't function quite as well as Nod's one. In your routine, you are asked whether to delete the original line from which to offset. That bit is fine. However, when you exit the routine, and use the offset command (not the off.lsp routine) the offset command still deletes the original line from which it has been offset. In Nods routine if you use the routine it deletes the original line, however, when you use the offset command it does not delete the original line from which it was offset. It is this functionality that I am looking for, but being a newbie to lisp am finding it difficult to code. hence I raised the question on this forum. So far as the theories of mathematics are about reality, they are not certain; so far as they are certain, they are not about reality. Albert Einstein. Quote
nod684 Posted October 24, 2012 Posted October 24, 2012 (edited) Try this one I've also adopted part of tharwat's code to check if layer is locked (thanks tharwat!) (defun c:off+ (/ *error* ent dist kwrd offset_side ) ;; 24 october 2012 nod684 (defun *error* (msg) (command "._undo" "_end") (setvar 'cmdecho cmd1) ) (command "._undo" "_begin") (setq cmd1 (getvar 'cmdecho)) (setvar 'cmdecho 0) (prompt "\nSelect Objects to Offset: ") (while (not ent) (setq ent (ssget "_+.:S:L" '((0 . "*LINE,CIRCLE,ELLIPSE")))) ) (initget (+ 1 2 4 64)) (setq dist (getdist "\nEnter offset distance: ")) (while (= offset_side nil) (setq offset_side (getpoint "\nSide to offset on: ")) ) (initget (+ 2 4) "Yes No") (setq kwrd (getkword "\nDelete source object [Yes/No] <Yes>: ")) (if (/= kwrd "No") (setq kwrd "Yes") ) (command "offset" "erase" "no" dist ent offset_side "") (if (eq kwrd "Yes") (command "erase" ent "") ) (*error* "") (princ "\nDone!") (princ)) Edited October 24, 2012 by nod684 Quote
Baber62 Posted October 24, 2012 Author Posted October 24, 2012 Nicely done Nod ... exactly what I was looking for. So far as the theories of mathematics are about reality, they are not certain; so far as they are certain, they are not about reality. Albert Einstein. Quote
nod684 Posted October 24, 2012 Posted October 24, 2012 Nicely done Nod ... exactly what I was looking for. glad to be of help mate! the routine is not perfect though. but still gives what you asked for. Quote
luiscarneirorm Posted October 24, 2012 Posted October 24, 2012 Nice routine. I found one error: If the offset it's not possible and i select the option errase original object, the object should not be deleted. Quote
nod684 Posted October 24, 2012 Posted October 24, 2012 (edited) Nice routine. I found one error: If the offset it's not possible and i select the option errase original object, the object should not be deleted. haven't experience that when i tested this i'll check on that. Thanks! EDIT : just checked it now and found no problem on my side... Edited October 25, 2012 by nod684 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.