Oh no!

Discussion in 'AutoCAD' started by Cad_Girl, Jun 30, 2004.

  1. Cad_Girl

    Cad_Girl Guest

    I have a mammoth task to complete and I really need help to find the quickest way of doing it!

    I have been given around 80 drawings that have been drawn in the wrong model space co-ords (non real world UCS). Now the powers that be have the correct co-ordinates, they want all the models moved to the right co-ords. So everything has to be moved in an X-Y direction and then rotated around a specific point.

    Another added problem is there are layers on and off, so I also need to save and recall a layer state.
    Can anyone please advise or help on the best way to do this?

    I have no idea on how to do something like this on lisp (and as usual, there is very little time to do it!).

    Any help in somehow automating this would be much appreciated.

    Cad_Girl
     
    Cad_Girl, Jun 30, 2004
    #1
  2. Cad_Girl

    BillZ Guest

    You could block the entire drawing while in the current UCS then set the UCS to world and insert the block.
    You may have to figure out what the best insert point and rotaion is.
    As far as automating:
    For 80 drawings, by the time you design a lisp, it may be just as quick to do it manually.
    I don't know a lot about layer states but I beleive you can save and import layer states.

    HTH

    Bill
     
    BillZ, Jun 30, 2004
    #2
  3. Hi!
     
    Alexander V. Koshman, Jun 30, 2004
    #3
  4. Cad_Girl

    coachball8 Guest

    I think I'd use a script and run it with ScriptPro.
     
    coachball8, Jun 30, 2004
    #4
  5. You have to visit http://www.multi-batch.com/
    and see their Multi-Batch 6.0!
    Very good tool as I think trying their 5.2 demo!
    Now they buy 6.0.
     
    Alexander V. Koshman, Jun 30, 2004
    #5
  6. Oh!
    -------
    You are absolutely right!
    I forgot about ScriptPro!.. : (
    --------------------------
    Alexander V. Koshman

    "coachball8" <> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
    ÓÌÅÄÕÀÝÅÅ:
    news:...
     
    Alexander V. Koshman, Jun 30, 2004
    #6
  7. Cad_Girl

    Doug Broad Guest

    As far as the move, if you want to use ActiveX
    methods, this should work:
    1) Use getucsmatrix to get the transformation matrix between
    WCS and that UCS.
    2) Invert the matrix(I think).
    3) Use the transformby method to change everything in model
    space to WCS.

    As far as the layer state, it depends on how you saved the
    layer state (express tools, layer command, custom layer command).

    Use a script to perform the changes in batch form.


    that be have the correct co-ordinates, they want all the models moved to the right co-ords. So everything has to be moved in an X-Y
    direction and then rotated around a specific point.
     
    Doug Broad, Jun 30, 2004
    #7
  8. Cad_Girl

    Devin Guest

    You're right Doug you have to create the inverted matrix to use transformby
    to go from UCS to world.

    I've got a program already created that searches a directory and all
    sub-directories and returns all the files it finds that match your criteria.
    You simply write lines to file for each member in the list creating a script
    to act on each file...

    ;;path=directory to start search
    ;;targpref=file prefix to match, nil for any
    ;;targext=file extension to match, nil for any

    (defun gather_files ( path targpref targext / filelst )
    (setq targext (strcat "." targext))
    (traverse_gather_files path (vl-directory-files path))
    filelst
    )

    (defun traverse_gather_files ( path dirlst / pref ext dirpath )
    (setq
    filelst
    (append filelst
    (vl-remove-if 'null
    (mapcar
    '(lambda (item)
    (cond
    (
    (vl-file-directory-p (strcat path "\\" item))
    (if
    (not (or (= item ".") (= item "..")))
    (progn
    (setq dirpath (strcat path "\\" item))
    (traverse_gather_files dirpath (vl-directory-files
    dirpath))
    )
    )
    )
    (t
    (setq
    pref (vl-filename-base item)
    ext (vl-filename-extension item)
    )
    (cond
    (
    (and
    (not targpref)
    (not targext)
    )
    (strcat path "\\" item)
    )
    (
    (not targpref)
    (if
    (= ext targext)
    (strcat path "\\" item)
    )
    )
    (
    (not targext)
    (if
    (= pref targpref)
    (strcat path "\\" item)
    )
    )
    (t
    (if
    (and (= pref targpref) (= ext targext))
    (strcat path "\\" item)
    )
    )
    )
    )
    )
    )
    dirlst
    )
    )
    )
    )
    )
     
    Devin, Jun 30, 2004
    #8
  9. Cad_Girl

    Devin Guest

    Only I don't now how the inverted matrix will work as the operations applied
    to the matrix are in reverse as well. I think transformby is designed to
    only go from world to ucs. But Bill and I tricked it by performing the
    translation portion of the transformation seperately, posted in an earlier
    post. Since this is a 2D operation I think it would be easier to simply
    move and rotate the data. A script would handle it pretty nicely I think.
    What are your thoughts?

    Devin
     
    Devin, Jun 30, 2004
    #9
  10. (vl-load-com)
    (setq LAob (vla-GetExtensionDictionary (vla-get-layers
    (vla-get-activedocument (vlax-get-acad-object)))))
    (setq LSob (vl-catch-all-apply 'vla-item (list LAob "ACAD_LAYERSTATES")))
    (if (not (vl-catch-all-error-p LSob))
    (vlax-for TT LSob (if (= (strcase (vla-get-name TT)) "TEMPSTATE") (command
    "Layer" "State" "Delete" "TempState" "" "")))
    )
    (command "Layer" "state" "save" "TempState" "" "" "")
    (command "layer" "T" "*" "ON" "*" "")
    (setq OS (getvar "OSMODE")
    (setvar "OSMODE" 0)
    (setq SS (ssget "ALL"))
    (if SS
    (progn
    ; do your commands here....... examples shown to move and rotate
    (command "MOVE" SS "" (list 0 0) (list 1 1))
    (command "ROTATE" SS "" (list 0 0) 50)
    )
    )
    (command "Layer" "state" "restore" "TempState" "" "")
    (command "Layer" "State" "Delete" "TempState" "" "")
    (setvar "OSMODE" OS)
     
    Alan Henderson @ A'cad Solutions, Jun 30, 2004
    #10
  11. Cad_Girl

    Devin Guest

    Please don't get me wrong though, there definately is a reverse matrix for
    every situation, I just am not sure it would apply to all objects equally.
    As it may vary per the location in space, since each item is rotated then
    translated or translated then rotated depending on the transformation
    direction (UCS -> WCS or WCS->UCS). As you could see, if the operations
    weren't done in the proper order it would give unexpected results. Since
    the transformby only performs the operations in one order or direction
    (WCS->UCS), I think the reverse matrix would have to be different for each
    object that's located at a different point out in space to get back to the
    same WCS.
     
    Devin, Jun 30, 2004
    #11
  12. Cad_Girl

    Devin Guest

    Alan,

    I'm not too familiar with scripts, but can all that be done within a script?
    If so then a combination of my file gather routine and your program written
    into a script for each of the files gathered I think would do what she
    needs.
     
    Devin, Jun 30, 2004
    #12
  13. Cad_Girl

    ECCAD Guest

    Alan,
    Kool. Now all she needs is EC-Batch to run all 80 drawings through in a minute or so.
    www.bobscadshop.com

    Bob
     
    ECCAD, Jun 30, 2004
    #13
  14. Cad_Girl

    Doug Broad Guest

    Doug Broad, Jun 30, 2004
    #14
  15. Yes, script file contains the program (written in lisp) and any other
    commands you would like (example ZOOM E, SAVE, etc)
     
    Alan Henderson @ A'cad Solutions, Jun 30, 2004
    #15
  16. Cad_Girl

    OLD-CADaver Guest

    Assuming everything is in one "space", and you're not using LT.

    Make sure all layers are unlocked, then (SSGET"X") will select everything in the database. ONce selected they can be moved and rotated. You can build a macro of such into a button, including save and close. Sorta like this (untested)

    ^c^c-layer;un;*;;(ssetget"X");move;p;;<v>;;rotate;p;;<bp>;<angle>;layerp;qsave;close;
     
    OLD-CADaver, Jun 30, 2004
    #16
  17. Cad_Girl

    Devin Guest

    Hi Doug,

    Yes I wonder if you tested that matrix completely? I haven't tested it, but
    I will in a bit. I know that the problem isn't in the matrix, but rather the
    transformation operation. Transformby performs an operation in one
    direction (to the matrix). The inverse operation transforms from the matrix
    to what's called the identity matrix. And it does that by performing the
    two operations in opposite sequence.

    There are two portions to the transformation matrix that you should be
    concerned about. The two parts are (and perhaps this is a repeat for you,
    but I must post for others) the rotation matrix that is a 3x3 matrix and a
    translation matrix that is a 1x3 matrix together they form the first three
    rows of the transformation matrix to make a 4x3 portion of the 4x4 finished
    matrix.

    operations performed are done using vectors in point values and performing
    calculations on that point against the 4x4 (or rather 4x3) matrix. Two
    calculations are done to the vector.

    During a transformation from the identity to the matrix (wcs->ucs) it
    multiplies the vector by the 3x3 rotation matrix and then afterwards adds
    the 1x3 translation matrix to the vector. The result is the vector
    transformed to the ucs.

    During a transformation from the matrix to the identity (ucs->wcs) it
    subtracts the 1x3 translation matrix from the vector and then afterwards,
    multiplies the vector by the transposition of the 3x3 rotation matrix (the
    inverse rotation matrix).

    As you can see the operations are rotate then move. Or the inverse is move
    back then rotate back.

    If you were to perform either operation out of sequence it would throw the
    vector out into space somewhere it's not supposed to be because of the
    rotation portion of the sequence, since the rotation portion is performed
    always in respect to the identity's 0,0,0 position. If the rotation is done
    out of sequence (which I beleive would be done if you tried to go to the wcs
    from a wcs->ucs function) it would perform the rotation portion from a base
    point other than it's supposed to since the point or object wasn't
    translated back first. The rotation would be done prematurely.

    But maybe you found a way around it, if you did then a big KUDOS to you.
    Anyways, I'm going to check it out myself and play around with your function
    there.

    Great thanks,

    Devin
     
    Devin, Jun 30, 2004
    #17
  18. Cad_Girl

    coachball8 Guest

    I see a lot of references to EC-batch, Bob. Is it better than ScriptPro? I assume it must be.
     
    coachball8, Jun 30, 2004
    #18
  19. Cad_Girl

    ECCAD Guest

    Visit my web site, there is a 'demo' working program that cuts you off at (5) drawings...the real (purchased) program does as many as you can grab. Will load up to (10) lisp programs, in order of pick, or (10) scripts..does an 'include' of those in order of pick. Purchase at $30.00

    Thanks for the question.

    Bob
    www.bobscadshop.com
     
    ECCAD, Jul 1, 2004
    #19
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.
Similar Threads
There are no similar threads yet.
Loading...