+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Junior Member
    Computer Details
    trefan123's Computer Details
    Operating System:
    win 10
    Computer:
    asus laptop i7
    Discipline
    Mechanical
    trefan123's Discipline Details
    Occupation
    Piping Designer
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    Jul 2017
    Location
    Traveller
    Posts
    13

    Unhappy Add previous objects to group

    Registered forum members do not see this ad.

    Good day,
    What i know is dangerous.
    I have a basic lisp that draws a couple of lines and arc's.
    ---------------
    (command "LINE" IP P4 P5 P6 P16 P15 P14 "C")
    (command "LINE" P1 P8 "")
    (command "LINE" P11 P18 "")
    (Command "arc" P5 P7 P8 "")
    (Command "arc" P8 P9 P18 "")
    (Command "arc" P18 P17 P15 "")
    ----------------------------------
    I would like to group these items for ease of manipulation.
    All help is appreciated.
    Thanks
    Peter

  2. #2
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,456

    Default

    Hi,
    something like:
    Code:
    (setq objlist (list (setq entity (entlast))))
    (command "LINE" IP P4 P5 P6 P16 P15 P14 "C")
    (command "LINE" P1 P8 "")
    (command "LINE" P11 P18 "")
    (Command "arc" P5 P7 P8 "")
    (Command "arc" P8 P9 P18 "")
    (Command "arc" P18 P17 P15 "")
    (while (setq entity (entnext entity))
      (setq objlist (cons (vlax-ename->vla-object entity) objlist))
    )
    (vlax-invoke 
      (vla-add (vla-get-groups (vla-get-activedocument (vlax-get-acad-object))) "*")
      'appenditems
      objlist
    )

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,563

    Default

    Here's another way, which may be easier to understand for a beginner:
    Code:
    (setq ent (entlast))
    (while (setq tmp (entnext ent)) (setq ent tmp))
    (command
        "_.line" "_non" IP   "_non" P4  "_non" P5 "_non" P6 "_non" P16 "_non" P15 "_non" P14 "_c"
        "_.line" "_non" P1   "_non" P8  ""
        "_.line" "_non" P11  "_non" P18 ""
        "_.arc"  "_non" P5   "_non" P7  "_non" P8
        "_.arc"  "_non" P8   "_non" P9  "_non" P18 
        "_.arc"  "_non" P18  "_non" P17 "_non" P15
        "_.-group" "_c" "*" "" 
    )
    (while (setq ent (entnext ent)) (command ent))
    (command "")
    @Grrr beware of circumstances in which the last entity in the database is complex (e.g. Heavy/3D polyline / attributed block)
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  4. #4
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,456

    Default

    Quote Originally Posted by Lee Mac View Post
    @Grrr beware of circumstances in which the last entity in the database is complex (e.g. Heavy/3D polyline / attributed block)
    Thanks Lee, I just understood what you did in the first two rows of your suggestion, and then I read your remark.

    Now I think that a subfunction that determines if an entity is parent (returns boolean), would pair nicely with entnext.

  5. #5
    Junior Member
    Computer Details
    trefan123's Computer Details
    Operating System:
    win 10
    Computer:
    asus laptop i7
    Discipline
    Mechanical
    trefan123's Discipline Details
    Occupation
    Piping Designer
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    Jul 2017
    Location
    Traveller
    Posts
    13

    Default

    Thanks a lot. I seem to grasp what lee added, i did try the entlast previously ..just errors...
    One question why put the non in front of the points?

  6. #6
    Junior Member
    Computer Details
    trefan123's Computer Details
    Operating System:
    win 10
    Computer:
    asus laptop i7
    Discipline
    Mechanical
    trefan123's Discipline Details
    Occupation
    Piping Designer
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    Jul 2017
    Location
    Traveller
    Posts
    13

    Default

    Here is the complete lisp, must have had the old one loaded as it worked but the addition fails
    (defun C:boltside (/ IP P1 P2 P3 SIZE)
    ;================make and choose color=========================
    (command "LAYER" "M" "Steel" "c" "green" "" "")
    (command "color" "white" "")
    (setvar 'osmode 53)
    ;=================insertion point========================
    (setvar "CMDECHO" 0)
    (setvar "BLIPMODE" 0)
    (setq IP (getpoint "\nInsertion Point: "))
    (setvar "OSMODE" 0)
    (setq SIZE (getreal "\nEnter the Nominal Bolt Size--Metric-: ")
    )
    ;====================get all points===================
    (setq P1 (polar IP (DTR 180.0) (* 0.4330 SIZE))
    P2 (polar IP (DTR 180.0) (* 0.6495 SIZE))
    P3 (polar IP (DTR 180.0) (* 0.7655 SIZE))
    P4 (polar IP (DTR 180.0) (* 0.8660 SIZE))
    P9 (polar IP (DTR 90.0) (* 0.8000 SIZE))
    P8 (polar P1 (DTR 90.0) (* 0.7420 SIZE))
    P7 (polar P2 (DTR 90.0) (* 0.8000 SIZE))
    P6 (polar P3 (DTR 90.0) (* 0.8000 SIZE))
    P5 (polar P4 (DTR 90.0) (* 0.7420 SIZE))
    P11 (polar IP (DTR 0.0) (* 0.4330 SIZE))
    P12 (polar IP (DTR 0.0) (* 0.6495 SIZE))
    P13 (polar IP (DTR 0.0) (* 0.7655 SIZE))
    P14 (polar IP (DTR 0.0) (* 0.8660 SIZE))
    P18 (polar P11 (DTR 90.0) (* 0.7420 SIZE))
    P17 (polar P12 (DTR 90.0) (* 0.8000 SIZE))
    P16 (polar P13 (DTR 90.0) (* 0.8000 SIZE))
    P15 (polar P14 (DTR 90.0) (* 0.7420 SIZE))
    )
    ;==================draw nut=======================
    (setq ent (entlast))
    (while (setq tmp (entnext ent)) (setq ent tmp))
    (command
    "_.line" "_non" IP "_non" P4 "_non" P5 "_non" P6 "_non" P16 "_non" P15 "_non" P14 "_c"
    "_.line" "_non" P1 "_non" P8 ""
    "_.line" "_non" P11 "_non" P18 ""
    "_.arc" "_non" P5 "_non" P7 "_non" P8
    "_.arc" "_non" P8 "_non" P9 "_non" P18
    "_.arc" "_non" P18 "_non" P17 "_non" P15
    "_.-group" "_c" "*" ""
    )
    (while (setq ent (entnext ent)) (command ent))
    (command "")
    ;================rotate to desired position=========================
    (prompt "\nRotation Angle: ")
    (command "ROTATE" "LAST" "" IP pause)
    ;================end=========================
    (setvar 'osmode 53)
    (princ)
    )

  7. #7
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,585

    Default

    Just a suggestion

    Code:
    (setq a90 (/ pi 2.0)) ; this is 90 degrees
    pi is 180 degrees use as is
    (setq a180 pi)
    (setq a270 (* pi 1.5)) this is 270 degrees
    
    P3 (polar IP pi (* 0.7655 SIZE))
    P18 (polar P11 a90 (* 0.7420 SIZE))
    A man who never made mistakes never made anything

  8. #8
    Junior Member
    Computer Details
    trefan123's Computer Details
    Operating System:
    win 10
    Computer:
    asus laptop i7
    Discipline
    Mechanical
    trefan123's Discipline Details
    Occupation
    Piping Designer
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    Jul 2017
    Location
    Traveller
    Posts
    13

    Embarrassed sorry forgot

    this was not copied
    (defun DTR (a) ;degrees to radians function
    (* PI (/ a 180.0))
    )

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,563

    Default

    Quote Originally Posted by trefan123 View Post
    One question why put the non in front of the points?
    This command modifier is short for "none" and instructs AutoCAD to ignore all active Object Snap modes for the next point input.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

  10. #10
    Junior Member
    Computer Details
    trefan123's Computer Details
    Operating System:
    win 10
    Computer:
    asus laptop i7
    Discipline
    Mechanical
    trefan123's Discipline Details
    Occupation
    Piping Designer
    Discipline
    Mechanical
    Using
    AutoCAD 2013
    Join Date
    Jul 2017
    Location
    Traveller
    Posts
    13

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Lee Mac View Post
    This command modifier is short for "none" and instructs AutoCAD to ignore all active Object Snap modes for the next point input.
    learn something every day..
    thanks again

Similar Threads

  1. select previous group via lisp problem...
    By danglar in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 1st Mar 2017, 09:07 pm
  2. Replies: 9
    Last Post: 12th Jan 2016, 01:48 pm
  3. Create selection set for previous objects
    By broncos15 in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 3rd Dec 2015, 03:57 pm
  4. Stretch a group of objects???!!
    By bbudding in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 5
    Last Post: 4th Nov 2009, 12:29 pm
  5. Viewing how Previous Objects were Created.
    By Jon B in forum AutoCAD General
    Replies: 8
    Last Post: 14th May 2008, 05:41 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