+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Senior Member harilalmn's Avatar
    Computer Details
    harilalmn's Computer Details
    Operating System:
    Win XP
    Discipline
    Architectural
    harilalmn's Discipline Details
    Occupation
    CAD Manager
    Discipline
    Architectural
    Using
    AutoCAD 2010
    Join Date
    Aug 2010
    Location
    Bangalore, India
    Posts
    115

    Default Picked point while picking an entity

    Registered forum members do not see this ad.

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

    Code:
    (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))
    )
    Harilal M. N.
    Bangalore, India.

    "Fill the brain with high thoughts, highest ideals, place them day and night before you, and out of that will come great work." - Swami Vivekananda.

  2. #2
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,635

    Default

    (setq pt2 (polar pt0 ang 100000000))<--you are setting a limit with this line

    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

    Code:
    (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)
      (while 
     (setq OffsetVal (getreal "\nOffset Distance:"))
     (setq OffsetVal (+ i OffsetVal))
         (command "_Offset" OffsetVal PickedEnt pt0 "")
         (setq i OffsetVal)
        )
    (princ)
    )
    HTH

  3. #3
    Senior Member harilalmn's Avatar
    Computer Details
    harilalmn's Computer Details
    Operating System:
    Win XP
    Discipline
    Architectural
    harilalmn's Discipline Details
    Occupation
    CAD Manager
    Discipline
    Architectural
    Using
    AutoCAD 2010
    Join Date
    Aug 2010
    Location
    Bangalore, India
    Posts
    115

    Default

    Thanks pBe, I will try that..!!
    Harilal M. N.
    Bangalore, India.

    "Fill the brain with high thoughts, highest ideals, place them day and night before you, and out of that will come great work." - Swami Vivekananda.

  4. #4
    Senior Member harilalmn's Avatar
    Computer Details
    harilalmn's Computer Details
    Operating System:
    Win XP
    Discipline
    Architectural
    harilalmn's Discipline Details
    Occupation
    CAD Manager
    Discipline
    Architectural
    Using
    AutoCAD 2010
    Join Date
    Aug 2010
    Location
    Bangalore, India
    Posts
    115

    Default

    I revised it as you adviced pBe,
    No it is working fine... Here it is..

    Code:
    (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))
    )
    Harilal M. N.
    Bangalore, India.

    "Fill the brain with high thoughts, highest ideals, place them day and night before you, and out of that will come great work." - Swami Vivekananda.

  5. #5
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,635

    Default

    Look at the sample code i posted harilalmn

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    16,789

    Default

    Another option:

    Code:
    Command: EXOFFSET
    
    Settings: Distance = Through,  Layer = SOURCE, Gaptype = Normal
    Specify offset distance or [Through] <Through>:
    
    Select object(s) to offset or [Options/Undo]:
    1 object(s) found.
    Shift+Pick for multiple; Ctrl+Pick to erase source object.
    Specify through point or [Multiple/Options/Undo]:
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  7. #7
    Senior Member harilalmn's Avatar
    Computer Details
    harilalmn's Computer Details
    Operating System:
    Win XP
    Discipline
    Architectural
    harilalmn's Discipline Details
    Occupation
    CAD Manager
    Discipline
    Architectural
    Using
    AutoCAD 2010
    Join Date
    Aug 2010
    Location
    Bangalore, India
    Posts
    115

    Default

    Registered forum members do not see this ad.

    Thanks Lee....!!
    Harilal M. N.
    Bangalore, India.

    "Fill the brain with high thoughts, highest ideals, place them day and night before you, and out of that will come great work." - Swami Vivekananda.

Similar Threads

  1. Getting cursor coordinates without picking a point
    By fonseca in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 2nd Apr 2014, 01:58 pm
  2. VBA - Getting an entity at a osnap point
    By Joro-- in forum .NET, ObjectARX & VBA
    Replies: 6
    Last Post: 27th Jul 2011, 04:02 am
  3. Finding a point in an Entity problem
    By Rob-GB in forum AutoLISP, Visual LISP & DCL
    Replies: 10
    Last Post: 1st Mar 2011, 06:00 pm
  4. Calculate Area by picking internal point
    By Bane in forum AutoLISP, Visual LISP & DCL
    Replies: 28
    Last Post: 22nd Dec 2009, 02:38 pm
  5. Selecting Objects Versus Picking a Point
    By BIGMIKE09281946 in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 29th Dec 2008, 08:25 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts