Too Many "select objects"

Discussion in 'AutoCAD' started by Clarence, Jan 6, 2005.

  1. Clarence

    Clarence Guest

    As a favor, I'm trying to fix another individual's "personal autolisp command" Here's some portions of the code:

    (SETQ SPEP (SSGET))

    the code between these portions, basically create a block (SPEP) and then insert that block (SPEP) at different coordinates......

    (while (not (eq etype "INSERT"))
    (setq e (car (entsel)))<<<<<<want to get rid of this
    (setq edata (entget e))
    (setq etype (cdr (assoc 0 edata)))
    )

    The end portion rotates the inserted block at it new coordinates.

    How do I reduce this down to selecting the objects one time only? I've tried variations that I've read from previous posts, and I haven't got it to work yet........
     
    Clarence, Jan 6, 2005
    #1
  2. Clarence

    Clarence Guest

    I've tried:

    (setq e spep)
    (if e
    (progn

    and I've tried:

    (setq e (car (ssname spep 0)))

    or at least something close to that....
     
    Clarence, Jan 6, 2005
    #2
  3. Clarence

    T.Willey Guest

    So the person want to rotate all the blocks that get inserted by there command? If some, then grab each block after it gets inserted (entlast) and add it to a list, then we there are done, do a foreach on the list of blocks.

    Tim
     
    T.Willey, Jan 6, 2005
    #3
  4. Clarence

    Clarence Guest

    clarification:

    it is making xrefs and/or any other objects into a block and then inserting that block at a different location and angle.

    So ssget is actually selecting multiple objects and entsel is where you select the block created from ssget.

    is it even possible to reduce this down to one "select objects" propmpt?

    Hi there, T, nice seeing you again! I'll give your suggestion a try and see how this goes.......

    Thanks!
     
    Clarence, Jan 6, 2005
    #4
  5. Clarence

    T.Willey Guest

    Can't you rotate it when you insert it?

    I see your working hard to get that one routine going?

    Good luck with them all.
    Tim
     
    T.Willey, Jan 6, 2005
    #5
  6. Clarence

    Clarence Guest

    I don't know exactly what this thing is supposed to accomplish. Seems very crude to me, but it's not for me, so I'll shut up. FYI - I want to remove one of the "select objects" and thats it.

    here's the code for this one:

    (DEFUN C:test ()
    (PROMPT
    "\nMOVE OBJECTS FROM EPPLEY COORDS TO STATE PLANES FT"
    )
    (setq OS (getvar "osmode"))
    (setvar "osmode" 0)
    (COMMAND "UNDO" "BEGIN")
    (SETQ OLDERR *ERROR*)
    (DEFUN *ERROR* (ERRMES)
    (PRINC
    (STRCAT "\nEP-SP HALTED BY THE FOLLOWING ERROR: " ERRMES)
    )
    (COMMAND "UNDO" "END")
    (SETQ *ERROR OLDERR)
    (COMMAND "UNDO" "1")
    )
    (SETQ SPEP (SSGET))
    (COMMAND "-block" "objecttobemoved"
    "2991908.80209610,616019.67552535"
    SPEP ""
    )
    (COMMAND "-insert" "objecttobemoved"
    "2768083.22150198,561217.87913841"
    "1" ""
    "0.0"
    )
    (setq etype nil
    e nil
    xscale 0.999623302
    yscale 0.999623302
    zscale 1
    )
    (command "zoom" "e")
    (PROMPT "\nSelect Block Again ---")
    (while (not (eq etype "INSERT"))
    (setq e (car (entsel)))
    (setq edata (entget e))
    (setq etype (cdr (assoc 0 edata)))
    )
    (setq edata (subst (cons 41 xscale) (assoc 41 edata) edata)) ; X
    (setq edata (subst (cons 42 yscale) (assoc 42 edata) edata)) ; Y
    (setq edata (subst (cons 43 zscale) (assoc 43 edata) edata)) ; Z
    (entmod edata)
    (COMMAND "ROTATE" E
    "" "2768083.22150198,561217.87913841"
    "2.68598424"
    )
    ; (COMMAND "EXPLODE" "L" "")
    (setvar "osmode" OS)
    (command "zoom" "e")
    (SETQ *ERROR* OLDERR)
    (COMMAND "UNDO" "END")
    (princ)
    )


    the other one, BOY! I got everything figured out, then I hit a fatal snag. Fields have limited options making my command useless. I had a dialog box set up to pick objects from any space and place the field text in any space. The only thing I needed to complete it, was to figure out the field expression so I could get square yards and acres as well as square feet. But that isn't possible as of right now, at least that what I'm guessing from my lack of responses to my ng posts lately. Oh well, I guess I'll just have to wait for Civil3d from what I've been told. Apparently it will be able to do my autolisp command, that or they have their own variation of it.


    Thanks for all of "your" help!
     
    Clarence, Jan 7, 2005
    #6
  7. Clarence

    T.Willey Guest

    See if this is what you are looking for. I commented out like 4 lines, and added one.

    Tim

    (DEFUN C:test ()
    (PROMPT
    "\nMOVE OBJECTS FROM EPPLEY COORDS TO STATE PLANES FT"
    )
    (setq OS (getvar "osmode"))
    (setvar "osmode" 0)
    (COMMAND "UNDO" "BEGIN")
    (SETQ OLDERR *ERROR*)
    (DEFUN *ERROR* (ERRMES)
    (PRINC
    (STRCAT "\nEP-SP HALTED BY THE FOLLOWING ERROR: " ERRMES)
    )
    (COMMAND "UNDO" "END")
    (SETQ *ERROR OLDERR)
    (COMMAND "UNDO" "1")
    )
    (SETQ SPEP (SSGET))
    (COMMAND "-block" "objecttobemoved"
    "2991908.80209610,616019.67552535"
    SPEP ""
    )
    (COMMAND "-insert" "objecttobemoved"
    "2768083.22150198,561217.87913841"
    "1" ""
    "0.0"
    )
    (setq etype nil
    e nil
    xscale 0.999623302
    yscale 0.999623302
    zscale 1
    )
    (command "zoom" "e")
    ;(PROMPT "\nSelect Block Again ---")
    ;(while (not (eq etype "INSERT"))
    ;(setq e (car (entsel)))
    (setq e (entlast)) ;<-- here is what I added
    (setq edata (entget e))
    (setq etype (cdr (assoc 0 edata)))
    ;)
    (setq edata (subst (cons 41 xscale) (assoc 41 edata) edata)) ; X
    (setq edata (subst (cons 42 yscale) (assoc 42 edata) edata)) ; Y
    (setq edata (subst (cons 43 zscale) (assoc 43 edata) edata)) ; Z
    (entmod edata)
    (COMMAND "ROTATE" E
    "" "2768083.22150198,561217.87913841"
    "2.68598424"
    )
    ; (COMMAND "EXPLODE" "L" "")
    (setvar "osmode" OS)
    (command "zoom" "e")
    (SETQ *ERROR* OLDERR)
    (COMMAND "UNDO" "END")
    (princ)
    )
     
    T.Willey, Jan 7, 2005
    #7
  8. Clarence

    T.Willey Guest

    Sorry to hear that you ran into a wall with your other one. I don't know anything about fields, but are you just trying to calculate the other areas? Could you just do the calculations within your routine, and the populate the fields, or is that not how fields are used?

    Hope something comes along fast so all that effort won't be wasted. No problems about the help, I like helping when I have time and are able to.

    Tim
     
    T.Willey, Jan 7, 2005
    #8
  9. Clarence

    Clarence Guest

    thanks for revising that code. He's gonna test it out and tell me what he thinks.

    here's what a field expression looks like:
    %<\AcObjProp Object(%<\_ObjId 2125216024>%).Area \f "%lu6%qf1">%

    The above expression (in A2k5), can be pasted into mtext dialog box and it will return area belonging to that object id.

    the portion after the word AREA is what controls how many decimals and what units, but there's no documentation describing this syntax so I can change it to what I want.

    And area is a read only variable so I can't set it to my calculations. I've tried many different approaches to this, and still haven't figured it out.

    here's the few extra options in addition to what autocad provides.
    http://www.cadforum.cz/cadforum_en/qaID.asp?tip=3676

    hope this gives you a better idea of how fields work......
     
    Clarence, Jan 7, 2005
    #9
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.