Jump to content

Picked point while picking an entity


harilalmn

Recommended Posts

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))
)

Link to comment
Share on other sites

(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

Link to comment
Share on other sites

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))
)

Link to comment
Share on other sites

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]:

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...