harilalmn Posted September 28, 2011 Share Posted September 28, 2011 Could someone tell me what I am doing wrong here? This routine is to repeatedly offset the picked entity with different offset values in the direction is specified. First 4-5 offsets are ok. But then it offsets a wrong entity... (defun c:QO( / PickedEnt pt0 Ent OSM OffsetTowards Ang i pt2 OffsetVal) (setq PickedEnt (entsel "\nPick Ent:")) (setq pt0 (cadr PickedEnt)) (setq Ent (car PickedEnt)) (setq OSM (getvar "OSMODE")) (setvar "osmode" 0) (setq OffsetTowards (getpoint pt0 "\nPick direction to offset:")) (setq Ang (angle pt0 OffsetTowards)) (setq i 1) (While (> i 0) (setq pt2 (polar pt0 ang 100000000)) (setq OffsetVal (getreal "\nOffset Distance:")) (command "_Offset" OffsetVal Ent pt2 "") (setq Ent (entlast)) (setq pt0 pt2) (setq i (1+ i)) ) ) (defun *error* (errmsg) (princ errmsg) (princ) (if (not (eq OSM nil))(setvar "OSMODE" OSM)) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted September 28, 2011 Share Posted September 28, 2011 (setq pt2 (polar pt0 ang 100000000)) I would suggest you use the first entity selected as base for every offset and record every distance you input, add the total + the new value for your OffsetVal variable, that way the direction would still be from the orginal entitiy no need to reassign value for pt2 but only increment the offset distance by total + new value and no need for entlast a simple code woudl be soemthing like this (defun c:test (/ PickedEnt pt0 i) (setq PickedEnt (entsel "\nPick Ent:")) (setq pt0 (cadr PickedEnt)) (setq pt0 ( getpoint pt0 "\nPick direction to offset:")) (setq i 0) [color=blue](while (setq OffsetVal (getreal "\nOffset Distance:")) (setq OffsetVal (+ i OffsetVal)) (command "_Offset" OffsetVal PickedEnt pt0 "") (setq i OffsetVal) ) [/color](princ) ) HTH Quote Link to comment Share on other sites More sharing options...
harilalmn Posted September 28, 2011 Author Share Posted September 28, 2011 Thanks pBe, I will try that..!! Quote Link to comment Share on other sites More sharing options...
harilalmn Posted September 28, 2011 Author Share Posted September 28, 2011 I revised it as you adviced pBe, No it is working fine... Here it is.. (defun c:QO( / PickedEnt pt0 Ent OSM OffsetTowards Ang i pt2 OffsetVal) (setq PickedEnt (entsel "\nPick Ent:")) (setq pt0 (cadr PickedEnt)) (setq Ent (car PickedEnt)) (setq OSM (getvar "OSMODE")) (setvar "osmode" 0) (setq OffsetTowards (getpoint pt0 "\nPick direction to offset:")) (setq Ang (angle pt0 OffsetTowards)) (setq OffsetVal 0) (setq i 1) (While (> i 0) (setq OffsetVal (+ OffsetVal (getreal "\nOffset Distance:"))) (setq pt2 (polar pt0 ang OffsetVal)) (command "_Offset" OffsetVal Ent pt2 "") (setq i (1+ i)) ) ) (defun *error* (errmsg) (princ errmsg) (princ) (if (not (eq OSM nil))(setvar "OSMODE" OSM)) ) Quote Link to comment Share on other sites More sharing options...
pBe Posted September 28, 2011 Share Posted September 28, 2011 Look at the sample code i posted harilalmn Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 28, 2011 Share Posted September 28, 2011 Another option: Command: EXOFFSET Settings: Distance = Through, Layer = SOURCE, Gaptype = Normal Specify offset distance or [[color=red]Through[/color]] <Through>: Select object(s) to offset or [Options/Undo]: 1 object(s) found. [color=red]Shift+Pick for multiple;[/color] Ctrl+Pick to erase source object. Specify through point or [[color=red]Multiple[/color]/Options/Undo]: Quote Link to comment Share on other sites More sharing options...
harilalmn Posted September 29, 2011 Author Share Posted September 29, 2011 Thanks Lee....!! Quote Link to comment Share on other sites More sharing options...
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.