Align method not supported?

Discussion in 'AutoCAD' started by BillZ, Jul 27, 2004.

  1. BillZ

    BillZ Guest

    R2005 Vlisp:

    I am working on a program that takes a list of triangles that have been drawn in various ucs's and am using a transformation matrix to move them to the WCS with their corners at z zero. This part works fine.
    Then I use the transformation matrix again to try to move them to their relative position with the other triangles. This works fairly well except when I calculate the base corner position from the last triangle for the next triangle, the accuracy is only within 0.0001 or so. You don't notice until you get 1000 triangles down the list, then it becomes apparent that the triangles overlap 0.01 to 0.08".
    Is there some way to "align" my triangles using 2 points?
    I check the methods of my 3D polyline triangles and don't see an align method although there seems to be a lot of other choices:
    Methods supported:
    ; AppendVertex (1)
    ; ArrayPolar (3)
    ; ArrayRectangular (6)
    ; Copy ()
    ; Delete ()
    ; Explode ()
    ; GetBoundingBox (2)
    ; GetExtensionDictionary ()
    ; GetXData (3)
    ; Highlight (1)
    ; IntersectWith (2)
    ; Mirror (2)
    ; Mirror3D (3)
    ; Move (2)
    ; Rotate (2)
    ; Rotate3D (3)
    ; ScaleEntity (2)
    ; SetXData (2)
    ; TransformBy (1)
    ; Update ()

    Thanks

    Bill
     
    BillZ, Jul 27, 2004
    #1
  2. BillZ

    Devin Guest

    Hi Bill,

    I noticed the same thing in transformations, I think it's due to sin-cos
    slight inconsistancies? Although I tend to doubt that, but it's the only
    conclusion I can draw. Perhaps someone else knows why. Anyways, once
    they're flat can't you simply move from the corner of one tri to the corner
    of the other tri. now you have one point aligned, then determine the angle
    between the next aligning corners and rotate them together?

    Devin
     
    Devin, Jul 27, 2004
    #2
  3. BillZ

    BillZ Guest

    Hi Devin,

    Yes the angles seem to have a descrepancy.

    I think too that the triangles may be changing slightly in geometry also when they are transformed. Maybe because of this. Not sure.
    Yes I'll find a work around. Just checking my options.
    They seem to transform fine to 0,0. So that would be my next step to "rotate/move/align" somehow.

    Thanks

    Bill
     
    BillZ, Jul 27, 2004
    #3
  4. BillZ

    BillZ Guest

    I just learned something new about the align command when you put it in a loop.

    It errors out and gives a message that says you cannot nest it more than 4 deep! :(

    Bill
     
    BillZ, Jul 27, 2004
    #4
  5. BillZ

    MP Guest

    Maybe you can add an error checking section that "reads" the triangle (size,
    angles, etc) both before transforms and after transforms with a fine degree
    of granularity so as to detect if and when they get modified (beyond your
    allowable tolerances) - even if just during the debug process - until you're
    sure you're getting reliable results (or maybe you're already doing that)

    ???just a thought

    interesting threads you two have been generating, I've enjoyed lurking and
    learning - or trying to - I also would like to understand matrix math better

    Keep up the good work
    :)
    Mark

    when they are transformed. Maybe because of this. Not sure.
     
    MP, Jul 27, 2004
    #5
  6. BillZ

    BillZ Guest

    Maybe you can add an error checking section that "reads" the triangle (size,
    angles, etc) both before transforms and after transforms with a fine degree
    of granularity so as to detect if and when they get modified (beyond your
    allowable tolerances) - even if just during the debug process - until you're
    sure you're getting reliable results (or maybe you're already doing that)

    ???just a thought
    <<<
    Mark.
    Thanks for the input.
    Accuracy of the transformed triangles would be key to accurate flat pattern. But I have already generated some excitement with what I can show them here so far with this basic program.

    Been a fun project all in all. :)

    Bill
     
    BillZ, Jul 27, 2004
    #6
  7. Read up on using external programs in the Developer's Guide.

    --
    R. Robert Bell


    I just learned something new about the align command when you put it in a
    loop.

    It errors out and gives a message that says you cannot nest it more than 4
    deep! :(

    Bill
     
    R. Robert Bell, Jul 27, 2004
    #7
  8. BillZ

    BillZ Guest

    I did a check on two of the legs and two of the angles for each triangle. Once at origin, once at first transformation and once at final placement. No changes in angles or length of legs were detected.
    So it must be a placement issue.
    Next I'll pursue Roberts suggestion and research external commands.

    Bill
     
    BillZ, Jul 28, 2004
    #8
  9. BillZ

    BillZ Guest

    I'm having a lottle trouble finding any info on the topic.

    Can you be more topic specific?
    I looked in both the Autolisp and ActiveX developers guides.

    Thx

    Bill
     
    BillZ, Jul 28, 2004
    #9
  10. AutoLISP Reference, Externally Defined Commands, Align

    --
    R. Robert Bell


    I'm having a lottle trouble finding any info on the topic.

    Can you be more topic specific?
    I looked in both the Autolisp and ActiveX developers guides.

    Thx

    Bill
     
    R. Robert Bell, Jul 28, 2004
    #10
  11. BillZ

    BillZ Guest

    Found it, thanks!

    Bill
     
    BillZ, Jul 28, 2004
    #11
  12. BillZ

    BillZ Guest

    Interestingly enough,
    After 132 times through the loop, the align command goes dead. After that, even if I type in "align" at the command prompt, It prompts me to select objects, so I select the triangle and hit enter and nothing else happens, It returns to the command prompt.

    So much for align.

    Bill
     
    BillZ, Jul 28, 2004
    #12
  13. BillZ

    BillZ Guest

    Found the answer in this NG.

    You have to feed the align function a selection set.

    Don't ask me why.


    Bill
     
    BillZ, Jul 29, 2004
    #13
  14. BillZ

    BillZ Guest

    Devin,

    I did find very small differences in the triangle leg lengths after transformations.
    I re-read and measured the distance between the corner points of each triangle after each transformation.

    Command: (rtos ob1xlen 2 22) ;at origin
    "4.203056214440523"

    Command: (rtos ob1xlen2 2 22) ;at 0,0,0
    "4.203056214440524"

    Command: (rtos ob1xlen3 2 22) ;at new placement
    "4.203056214440545"

    Command: (rtos ob1ylen 2 22) ;at origin
    "1.190832206495775"

    Command: (rtos ob1ylen2 2 22) ;at 0,0,0
    "1.190832206495771"

    Command: (rtos ob1ylen3 2 22) ;at new location
    "1.190832206495798"

    I know these numbers are very, very small, but it makes me wonder if this is why I cannot place them without a bit of mis-alignment?

    Bill
     
    BillZ, Jul 29, 2004
    #14
  15. BillZ

    Joe Burke Guest

    Bill,

    That's right. The why is because the align function expects a selection set. It
    deletes the ss after each pass of the command.

    On the other hand, if you feed it two objects, it creates a selection set. And when
    the number of selection sets exceeds 128... dead-in-the-water.

    Joe Burke
     
    Joe Burke, Jul 30, 2004
    #15
  16. BillZ

    BillZ Guest

    On the other hand, if you feed it two objects, it creates a selection set. And when
    the number of selection sets exceeds 128... dead-in-the-water.
    <<<

    Kinda what I was thinking...
    And it does it even when fed ONE ename.
    selection set is the way to go.

    Thanks

    Bill
     
    BillZ, Jul 30, 2004
    #16
  17. BillZ

    BTO Guest

    hi, my 2 cents advise

    get datas from 3dpoly => ( (triangle_1_vertex_A, triangle_1_vertex_B,
    triangle_1_vertex_C) (triangle_2_vertex_A, triangle_2_vertex_B,
    triangle_2_vertex_C)........)
    some 2D mathematics (1 translation and 1 rotation) :))
    drawn new entities.

    Bruno Toniutti.
     
    BTO, Aug 2, 2004
    #17
  18. BillZ

    Devin Guest

    Bill,

    Looking at the code I would have to say that most likely the error is due to
    either non-planar or non-perpendicular points used in creating the matrix.
    It probably occures in the 3pxa_matrix function. The function takes and
    creates an origin, x, y and z direction points then converts the direction
    points to unit vectors. I bet that the direction points are slightly off.
    In order to create a more accurate matrix the points need to be precisely
    perpendicular to each other on their respective planes from the origin.

    When I get some free time I'll look into it. Perhaps you'll find a fix
    sooner. Just leave the following portion of the code alone and focus on the
    code above it that calcs the direction points...

    (setq
    xo (car org)
    yo (cadr org)
    zo (caddr org)
    xx (car -x)
    yx (cadr -x)
    zx (caddr -x)
    xy (car -y)
    yy (cadr -y)
    zy (caddr -y)
    xz (car -z)
    yz (cadr -z)
    zz (caddr -z)
    numx (sqrt (+ (sqr (- xx xo)) (sqr (- yx yo)) (sqr (- zx zo))))
    numy (sqrt (+ (sqr (- xy xo)) (sqr (- yy yo)) (sqr (- zy zo))))
    numz (sqrt (+ (sqr (- xz xo)) (sqr (- yz yo)) (sqr (- zz zo))))
    v (vector (list 0.0 0.0 0.0) origin)
    ucs_matrix
    (list
    (list (/ (- xx xo) numx) (/ (- xy xo) numy) (/ (- xz xo) numz) (car
    v))
    (list (/ (- yx yo) numx) (/ (- yy yo) numy) (/ (- yz yo) numz) (cadr
    v))
    (list (/ (- zx zo) numx) (/ (- zy zo) numy) (/ (- zz zo) numz) (caddr
    v))
    (list 0.0 0.0 0.0 1.0)
    )
    ucs_matrix_array (vlax-tmatrix ucs_matrix)
    )
    ucs_matrix
     
    Devin, Aug 2, 2004
    #18
  19. BillZ

    BillZ Guest

    some 2D mathematics (1 translation and 1 rotation) :))
    drawn new entities.<<

    Do you have the code that shows how to do this?


    Bill
     
    BillZ, Aug 2, 2004
    #19
  20. BillZ

    BillZ Guest

    When I get some free time I'll look into it. <<<

    Great, let me know if you find a fix.

    I'll be exausting my options in the mean time. :)
    code above it that calcs the direction points...<<<

    The code above looks like the axial rotate part itself....hmmm.

    Thanks

    Bill
     
    BillZ, Aug 4, 2004
    #20
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.