DXF Codes 10 and 210 Formula

Discussion in 'AutoCAD' started by sheldonmcc, Sep 14, 2004.

  1. sheldonmcc

    sheldonmcc Guest

    I was told to post this here. If I see copy and pasted AutoDesk documentation on the Arbitrary Axis Alogorithm again with no examples, I'll cry...

    I cannot belive that nobody has an answer for this question regarding DXF codes and WCS values (please do not refer me to the AutoCAD Help on this one since I'm working outside of AutoCAD and in VB6 creating DXF files).

    So far, all I have discovered is the OCS and WCS are different and they require translation. Since my application is outside of AutoCAD, the LISP function "TRANS" does not apply (or any other LISP function for that matter).

    I need a block to be inserted 45 degrees to the XY plane and down 45 from the XY plane in AutoCAD, but coming from a VB6 generated DXF file. While testing inside AutoCAD, the coordinate values using the LIST command for the block are different from the DXF values given for codes 10 and 210. In fact, they are not even close. My block has 2 known sets of start/end coordinates outside of AutoCAD (eg. a valve). Surely there must be a formula to calculate the 10 and 210 codes for a DXF file based on the 2 known sets of coordinates. The formula should work no matter what angle the block needs to be inserted at (even a simple insertion at 0 degrees at coordinates 0,0,0).

    If there are any brainiacs out there to tackle this month old problem for me, I promise to put you on my Christmas card list.

    I have researched the Arbitrary Axis Alogarithm but the documentation provided by AutoDesk provides no examples and is not very clear.

    Signed.....Confused in Calgary
     
    sheldonmcc, Sep 14, 2004
    #1
  2. First of all, you must have Autocad in your posession, if you think to write
    dxf-code from outside, believe me.
    You cannot manage without.

    To the point:
    Code 10 is allways x-coordinate value, 20 is y and 30 is for z. After some
    small testing I see, that there is actually 210, 220 and 230 and they seem
    to be direction vector values. With very small examination you can find the
    figures.
    For 45 deg they are 0.7071067811865475, but sign and presence in 210,220
    and 230 I leave to you.

    Matti
     
    Matti Pitkänen, Sep 14, 2004
    #2
  3. the coordinate values using the LIST command for the block are different
    from the DXF values

    This is the result of the process of transforming the user entered
    coordinates into OCS coordinates.
    The arbitrary axis algorithm (AAA) is used to generate the OCS coordinates
    from the WCS coordinates.
    I don't believe there is a way to get the original entered UCS coordinates
    from the OCS coordinates, if that is what you're looking for.

    What you have to do in your VB program is start off with WCS coordinates and
    generate the OCS using the AAA
    Since you already read the help on the AAA, I won´t go copying that, so
    don´t start crying !!

    The first rule: the WCS origin and the OCS origin should be the same.
    You have to start off with a normal vector (N) which is your Z vector
    [remember a vector is in the form (0,0,1)]
    Then calculate the Ax and Ay (arbitrary OCS) axis using the cross product of
    the corresponding WCS vector and the Normal vector
    For example,to get axis Ax, use the cross product of Wx X N (depends on the
    1/64 boundary explained in the help)

    Ax= ( WXy*Nz-WXz* Ny, WXz*Nx-WXx*Nz, WXx*Ny-WXy* Nx)
     
    Jorge Jimenez, Sep 15, 2004
    #3
  4. sheldonmcc

    sheldonmcc Guest

    Jorge,
    What is the "Cross Product"? Can you throw some numbers into an example for me please.

    Muchas gracias por su ayuda...
     
    sheldonmcc, Sep 15, 2004
    #4
  5. sheldonmcc

    sheldonmcc Guest

    Jorge,

    Maybe I am better to give some numbers I'm working with, then you can show me in an example. I can take it from there.

    P1 = 5500, 6600, 7700
    P2 = 5503.0154, 6603.4688,7695.4038

    P1 is the insertion point of the valve and P2 is the other end of the valve. The block is defined as: P1 to P2 is the x-axis, which is exactly 1.0 units (I scaled this block according to the 3D distance calculated between P1 and P2. In this case, it is 6.5 units long).

    This is the result in AutoCAD when using LISP (remember, I'm not programming in LISP, only using it to confirm the values required when I make a DXF file).

    Command: (entget (car (entsel)))

    Select object: ((-1 . <Entity name: 40070e90>) (0 . "INSERT") (330 . <Entity
    name: 40070cf8>) (5 . "8A") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
    "2") (100 . "AcDbBlockReference") (2 . "valve") (10 8589.41 7700.0 -179.087)
    (41 . 6.5) (42 . 6.5) (43 . 6.5) (50 . 5.49779) (70 . 0) (71 . 0) (44 . 0.0)
    (45 . 0.0) (210 0.75471 -0.656059 -2.05687e-016))


    And the AutoCAD "List" command:

    Command: list
    Select objects: 1 found
    Select objects:
    BLOCK REFERENCE Layer: "2"
    Space: Model space
    Handle = 8A
    "valve"
    at point, X=5500.0000 Y=6600.0000 Z=7700.0000
    X scale factor 6.5000
    Y scale factor 6.5000
    Z scale factor 6.5000
    Extrusion direction relative to UCS:
    X= 0.7547 Y= -0.6561 Z= 0.0000

    De nuevo.....muchas gracias....
     
    sheldonmcc, Sep 15, 2004
    #5
  6. The Cross Product is the perpendicular vector to Wx and N
     
    Jorge Jimenez, Sep 16, 2004
    #6
  7. For the numbers you're showing here:

    1) Was the block inserted manually using Insert ??

    2) What was the current UCS when you inserted the Block ??

    3) What was the current UCS when you listed the block ??
     
    Jorge Jimenez, Sep 16, 2004
    #7
  8. sheldonmcc

    sheldonmcc Guest

    Jorge,

    1) Yes, the block was inserted manually using insert. If I wrote the listed numbers and codes in a DXF, I get the same results as a manual insert.
    2) The UCS during insert was default
    3) The UCS during listing was default

    Also, the application I am writing is for 3D.

    Don't forget, I am writing this code in Visual Basic, therefore all the codes I list in AutoCAD must be calculated and put into the DXF. I have some of this code written, but I am stuck on the group 10 codes, and the Z value of the group 210 code.

    Gracias.....
     
    sheldonmcc, Sep 16, 2004
    #8
  9. sheldonmcc

    sheldonmcc Guest

    Jorge,

    The answer was given to me by a posting on the other discussion group....thanks so much for your help!

    It now works in VB, 2 given XYZ points. Block inserted as required.

    Chao!
     
    sheldonmcc, Sep 18, 2004
    #9
  10. Sorry I couldn't answer sooner.
    Glad you got your answer
     
    Jorge Jimenez, Sep 20, 2004
    #10
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.