+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 29
  1. #1
    Super Member Lt Dan's legs's Avatar
    Using
    AutoCAD 2007
    Join Date
    May 2010
    Location
    Florida
    Posts
    611

    Default Beginner question

    Registered forum members do not see this ad.

    How do I set a definition as the last object selected without having a command active?

    excuse my simple lisp example:
    (command "_move" "L" <-----

    In this example I'm just pointing out what I mean by last object.

    Allen,
    I'm sure it's in the files you shared with me but I wasn't able to find it

  2. #2
    Forum Deity
    Using
    Civil 3D 2008
    Join Date
    Sep 2006
    Location
    Pittsburgh, PA, USA
    Posts
    3,581

    Default

    "L" doesn't provide you with the last object selected, it provides you with the last entity created; also accessed with (entlast)

  3. #3
    Super Moderator Tiger's Avatar
    Computer Details
    Tiger's Computer Details
    Operating System:
    Windows 7 Professional 64 bit
    Computer:
    HP EliteBook 8570w
    CPU:
    Intel Core i7-3720QM 2.60GHz
    RAM:
    16GB
    Graphics:
    NVIDIA Quadro K2000M
    Monitor:
    HP
    Discipline
    Civil
    Tiger's Discipline Details
    Occupation
    Education /support
    Discipline
    Civil
    Details
    Support/Education/Retail
    Using
    Civil 3D 2016
    Join Date
    Nov 2006
    Location
    FjÀrdhundra, Sweden
    Posts
    5,148

    Default

    eh...I am not familiar with Lisp at all so forgive me if I stumble into something I don't know - but if you hit P and the "select objects"-prompt you get the last (previous) selection..is that what you are after?
    MTJIGSTRING = BAZINGA

  4. #4
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Code:
    (ssget "_P")
    FYI: Alan
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  5. #5
    Super Member Lt Dan's legs's Avatar
    Using
    AutoCAD 2007
    Join Date
    May 2010
    Location
    Florida
    Posts
    611

    Default

    Quote Originally Posted by alanjt View Post
    FYI: Alan
    Sorry for that. The sun was in my eyes


    ___

    It made me laugh when I tried to do a quick reply and a message pops up

    Sending quick reply - please wait
    Last edited by Lt Dan's legs; 11th Jun 2010 at 03:01 pm. Reason: Noticed a message

  6. #6
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by Lt Dan's legs View Post
    Sorry for that. The sun was in my eyes
    No biggie. It doesn't bother me; I just wanted to eliminate the mix-up from the beginning.



    Did that get you what you wanted?
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  7. #7
    Super Member Lt Dan's legs's Avatar
    Using
    AutoCAD 2007
    Join Date
    May 2010
    Location
    Florida
    Posts
    611

    Default

    It came up with

    ; error: syntax error

    should it be as simple as (setq x (ssget "_P"))

  8. #8
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by Lt Dan's legs View Post
    It came up with

    ; error: syntax error

    should it be as simple as (setq x (ssget "_P"))
    Works fine on my end. Check for typos.
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  9. #9
    Super Member Lt Dan's legs's Avatar
    Using
    AutoCAD 2007
    Join Date
    May 2010
    Location
    Florida
    Posts
    611

    Default

    I think my problem was (( )).. now I get

    ; error: bad argument type: consp <Selection set: 268>

  10. #10
    Super Member Lt Dan's legs's Avatar
    Using
    AutoCAD 2007
    Join Date
    May 2010
    Location
    Florida
    Posts
    611

    Default

    Registered forum members do not see this ad.

    okay I'm trying to edit this code. this code is exactly what I need but instead of selecting a line with the mouse I want to select the previous object.

    Code writen by Terry Miller

    Code:
    ;-------------------------------------------------------------------------------
    ; Program Name: DPL - Dimension Polylines
    ; Created By: Terry Miller (Email: terrycadd@yahoo.com)
    ; (URL: http://web2.airmail.net/terrycad)
    ; Date Created: 5-20-08
    ; Function: Dimensions Polyline shapes
    ;-------------------------------------------------------------------------------
    ; Revision History
    ; Rev By Date Description
    ;-------------------------------------------------------------------------------
    ; 1 TM 5-20-08 Initial version
    ;-------------------------------------------------------------------------------
    ; c:DPL - Dimensions Polyline
    ;-------------------------------------------------------------------------------
    (defun c:DPL (/ EntName^ EntPick@)
    (setvar "CMDECHO" 0)
    (if (setq EntPick@ (entsel "\nSelect Polyline to dimension: "))
    (if (= (cdr (assoc 0 (entget (car EntPick@)))) "LWPOLYLINE")
    (progn
    (setq EntName^ (cdr (assoc -1 (entget (car EntPick@)))))
    (DimPL EntName^)
    );progn
    );if
    );if
    (if (not EntName^)
    (princ "\nNo Polyline selected.")
    );if
    (princ)
    );defun c:DPL
    ;-------------------------------------------------------------------------------
    ; DimPL - Function to dimension Polyline
    ; Arguments: 1
    ; EntName^ = Polyline entity name
    ; Returns: Dimensions Polyline
    ;-------------------------------------------------------------------------------
    (defun DimPL (EntName^ / Bottom@ Clayer$ CW# DiffAng DimPts: DimSpace~ EntList@
    Item LastAng~ LastPt Left@ List@ NW@ Osmode# P0 P1 P2 Pt Pts@ PtsLen Right@ SE@
    Top@ X~ X1~ X1Y1 X1Y2 X1Ys@ X2~ X2Y1 X2Y2 X2Ys@ XPts@ Y~ Y1~ Y1X1 Y1X2 Y1Xs@ Y2~
    Y2X1 Y2X2 Y2Xs@ YPts@)
    ;-----------------------------------------------------------------------------
    (defun DimPts: (Pts@ StartPt EndPt Type$ / Add Num1~ Num2~ Nums1@ Nums2@ P1 P2
    Pt Return@)
    (setq Add t)
    (foreach Pt (member StartPt (append Pts@ Pts@))
    (if Add
    (setq Return@ (append Return@ (list Pt)))
    );if
    (if (equal Pt EndPt)
    (setq Add nil)
    );if
    );foreach
    (foreach Pt Return@
    (if (member Type$ (list "Left" "Right"))
    (setq Nums1@ (append Nums1@ (list (cadr Pt))))
    (setq Nums1@ (append Nums1@ (list (car Pt))))
    );if
    );foreach
    (foreach Num1~ (vl-sort Nums1@ '<)
    (setq Nums2@ nil)
    (foreach Pt Return@
    (if (member Type$ (list "Left" "Right"))
    (if (= (cadr Pt) Num1~)
    (setq Nums2@ (append Nums2@ (list (car Pt))))
    );if
    (if (= (car Pt) Num1~)
    (setq Nums2@ (append Nums2@ (list (cadr Pt))))
    );if
    );if
    );foreach
    (if (member Type$ (list "Left" "Bottom"))
    (setq Nums2@ (vl-sort Nums2@ '<))
    (setq Nums2@ (reverse (vl-sort Nums2@ '<)))
    );if
    (foreach Num2~ (cdr Nums2@)
    (if (member Type$ (list "Left" "Right"))
    (setq Pt (list Num2~ Num1~))
    (setq Pt (list Num1~ Num2~))
    );if
    (setq Return@ (vl-remove Pt Return@))
    );foreach
    );foreach
    (cond
    ((= Type$ "Left")
    (vl-sort Return@ (function (lambda (P1 P2)(< (cadr P1)(cadr P2)))))
    );case
    ((= Type$ "Top")
    (vl-sort Return@ (function (lambda (P1 P2)(< (car P1)(car P2)))))
    );case
    ((= Type$ "Right")
    (vl-sort Return@ (function (lambda (P1 P2)(> (cadr P1)(cadr P2)))))
    );case
    ((= Type$ "Bottom")
    (vl-sort Return@ (function (lambda (P1 P2)(> (car P1)(car P2)))))
    );case
    );cond
    );defun DimPts:
    ;-----------------------------------------------------------------------------
    (setq EntList@ (entget EntName^))
    (if (= (cdr (assoc 0 EntList@)) "LWPOLYLINE")
    (progn
    (foreach List@ EntList@
    (if (= (car List@) 10)
    (if (not (equal (cdr List@) LastPt))
    (progn
    (setq Pts@ (append Pts@ (list (cdr List@))))
    (if (> (length Pts@) 2)
    (if (/= (angle LastPt (cdr List@)) LastAng~) (setq DiffAng t))
    );if
    (if (> (length Pts@) 1)
    (setq LastAng~ (angle LastPt (cdr List@)))
    );if
    (setq LastPt (cdr List@))
    );progn
    );if
    );if
    );foreach
    (if (equal (car Pts@) (last Pts@))
    (setq Pts@ (reverse (cdr (reverse Pts@))))
    );if
    (setq PtsLen (length Pts@))
    );progn
    (exit)
    );if
    (foreach Pt Pts@
    (setq X~ (atof (rtos (car Pt) 2 8))
    Y~ (atof (rtos (cadr Pt) 2 8))
    XPts@ (append XPts@ (list X~))
    YPts@ (append YPts@ (list Y~))
    Pts@ (cdr (append Pts@ (list (list X~ Y~))))
    );setq
    );foreach
    (setq XPts@ (vl-sort XPts@ '<)
    YPts@ (vl-sort YPts@ '<)
    X1~ (car XPts@)
    X2~ (last XPts@)
    Y1~ (car YPts@)
    Y2~ (last YPts@)
    );if
    (foreach Pt Pts@
    (if (= (car Pt) X1~) (setq X1Ys@ (append X1Ys@ (list (cadr Pt)))))
    (if (= (car Pt) X2~) (setq X2Ys@ (append X2Ys@ (list (cadr Pt)))))
    (if (= (cadr Pt) Y1~) (setq Y1Xs@ (append Y1Xs@ (list (car Pt)))))
    (if (= (cadr Pt) Y2~) (setq Y2Xs@ (append Y2Xs@ (list (car Pt)))))
    );foreach
    (setq X1Ys@ (vl-sort X1Ys@ '<)
    X2Ys@ (vl-sort X2Ys@ '<)
    Y1Xs@ (vl-sort Y1Xs@ '<)
    Y2Xs@ (vl-sort Y2Xs@ '<)
    X1Y1 (list X1~ (car X1Ys@))
    X1Y2 (list X1~ (last X1Ys@))
    X2Y1 (list X2~ (car X2Ys@))
    X2Y2 (list X2~ (last X2Ys@))
    Y1X1 (list (car Y1Xs@) Y1~)
    Y1X2 (list (last Y1Xs@) Y1~)
    Y2X1 (list (car Y2Xs@) Y2~)
    Y2X2 (list (last Y2Xs@) Y2~)
    Pts@ (member X1Y1 (append Pts@ Pts@))
    );setq
    (while (> (length Pts@) PtsLen)
    (setq Pts@ (reverse (cdr (reverse Pts@))))
    );while
    (setq SE@ (member X2Y2 Pts@) NW@ Pts@)
    (foreach Item SE@
    (setq NW@ (vl-remove Item NW@))
    );foreach
    (setq SE@ (append SE@ (list X1Y1))
    NW@ (append NW@ (list X2Y2))
    CW# 0
    );setq
    (foreach Pt (list Y2X1 Y2X2)
    (if (member Pt NW@) (setq CW# (1+ CW#)))
    (if (member Pt SE@) (setq CW# (1- CW#)))
    );foreach
    (foreach Pt (list Y1X1 Y1X2)
    (if (member Pt SE@) (setq CW# (1+ CW#)))
    (if (member Pt NW@) (setq CW# (1- CW#)))
    );foreach
    (if (< CW# 0)
    (setq Pts@ (append (list (car Pts@))(reverse (cdr Pts@))))
    );if
    (setq Left@ (DimPts: Pts@ Y1X1 Y2X1 "Left"))
    (setq Top@ (DimPts: Pts@ X1Y2 X2Y2 "Top"))
    (setq Right@ (DimPts: Pts@ Y2X2 Y1X2 "Right"))
    (setq Bottom@ (DimPts: Pts@ X2Y1 X1Y1 "Bottom"))
    ;-----------------------------------------------------------------------------
    (command "UNDO" "BEGIN")
    (setq DimSpace~ (* (getvar "DIMSCALE") (getvar "DIMTXT") 3))
    (setq Osmode# (getvar "OSMODE")) (setvar "OSMODE" 0)
    (setq Clayer$ (getvar "CLAYER"))
    (command "LAYER" "S" "DIM" "");<--Change to your Dim layer info
    (setq P0 (polar X1Y1 pi (* DimSpace~ 1.5))
    P1 (car Left@)
    );setq
    (foreach P2 (cdr Left@)
    (command "DIM1" "VER" P1 P2 P0 "")
    (setq P1 P2)
    );foreach
    (if (> (length Left@) 2)
    (progn
    (setq P0 (polar P0 pi DimSpace~))
    (command "DIM1" "VER" (car Left@) (last Left@) P0 "")
    );progn
    );if
    (setq P0 (polar Y2X1 (* pi 0.5) (* DimSpace~ 1.5))
    P1 (car Top@)
    );setq
    (foreach P2 (cdr Top@)
    (command "DIM1" "HOR" P1 P2 P0 "")
    (setq P1 P2)
    );foreach
    (if (> (length Top@) 2)
    (progn
    (setq P0 (polar P0 (* pi 0.5) DimSpace~))
    (command "DIM1" "HOR" (car Top@) (last Top@) P0 "")
    );progn
    );if
    (setq P0 (polar X2Y2 0 (* DimSpace~ 1.5))
    P1 (car Right@)
    );setq
    (if (and (> (length Right@) 2) DiffAng)
    (foreach P2 (cdr Right@)
    (command "DIM1" "VER" P1 P2 P0 "")
    (setq P1 P2)
    );foreach
    );if
    (setq P0 (polar Y1X2 (* pi 1.5) (* DimSpace~ 1.5))
    P1 (car Bottom@)
    );setq
    (if (and (> (length Bottom@) 2) DiffAng)
    (foreach P2 (cdr Bottom@)
    (command "DIM1" "HOR" P1 P2 P0 "")
    (setq P1 P2)
    );foreach
    );if
    (setvar "CLAYER" Clayer$)
    (setvar "OSMODE" Osmode#)
    (command "UNDO" "END")
    (princ)
    );defun DimPL
    ;-------------------------------------------------------------------------------
    ; GetDimLayer - Returns the layer name that's on and has the most dimensions,
    ; or the current layer name if there's no dimensions.
    ;-------------------------------------------------------------------------------
    (defun GetDimLayer (/ DimLayer$ EntList@ Index# Layer$ LayerInfo@ LayerList@ List@ Num# SS&)
    (setq Layer$ (getvar "CLAYER"))
    (if (setq SS& (ssget "X" '((0 . "DIMENSION"))))
    (progn
    (setq Index# -1)
    (while (< (setq Index# (1+ Index#)) (sslength SS&))
    (setq EntList@ (entget (ssname SS& Index#))
    DimLayer$ (cdr (assoc 8 EntList@))
    LayerInfo@ (tblsearch "LAYER" DimLayer$)
    );setq
    (if (and (= (cdr (assoc 70 LayerInfo@)) 0)(> (cdr (assoc 62 LayerInfo@)) 0))
    (if (assoc DimLayer$ LayerList@)
    (setq Num# (1+ (cdr (assoc DimLayer$ LayerList@)))
    LayerList@ (subst (cons DimLayer$ Num#) (assoc DimLayer$ LayerList@) LayerList@)
    );setq
    (setq LayerList@ (append LayerList@ (list (cons DimLayer$ 1))))
    );if
    );if
    );while
    (if LayerList@
    (progn
    (setq Layer$ (car (car LayerList@))
    Num# (cdr (car LayerList@))
    );setq
    (foreach List@ (cdr LayerList@)
    (if (> (cdr List@) Num#)
    (setq Layer$ (car List@)
    Num# (cdr List@)
    );setq
    );if
    );foreach
    );progn
    );if
    );progn
    );if
    Layer$
    );defun GetDimLayer
    ;-------------------------------------------------------------------------------
    (princ);End of DPL.lsp

Similar Threads

  1. super beginner question-steps
    By richie_008 in forum AutoCAD Beginners' Area
    Replies: 10
    Last Post: 24th Feb 2009, 11:37 pm
  2. Beginner FAQ
    By Mr T in forum AutoCAD Beginners' Area
    Replies: 13
    Last Post: 11th Feb 2009, 10:20 pm
  3. Beginner 3D Help
    By Ritch7 in forum AutoCAD 3D Modelling & Rendering
    Replies: 4
    Last Post: 26th Nov 2008, 04:17 pm
  4. beginner in 3d
    By chrisdarmanin in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 22nd Jan 2008, 03:01 pm
  5. beginner
    By manyos in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 18th Feb 2006, 08:16 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