Can I find the angle of a line contained in a hatch pattern?

Discussion in 'AutoCAD' started by Dave F., Jul 20, 2004.

  1. Dave F.

    Dave F. Guest

    Hi
    In lisp dxf code 53 for a hatch gave the pattern line angle.

    Is it possible to retrieve this in VBA?

    Thanks in advance
    Dave F.
     
    Dave F., Jul 20, 2004
    #1
  2. Dave F.

    Dave F. Guest

    Hi Tom
    No, that's the angle of the whole pattern.

    What I'm after is the angle of an individual line that makes up the hatch
    pattern.
    I thought you might be able to get it from GetSubEntity but I can't work it
    out.

    This is the info I need. It's from the dxf reference. Hatch pattern data
    group codes
    Group codes Description
    53 Pattern line angle
    43 Pattern line base point, X component
    44 Pattern line base point, Y component
    45 Pattern line offset, X component
    46 Pattern line offset, Y component
    79 Number of dash length items
    49 Dash length (multiple entries)


    Any Ideas?
    Thanks in advance

    Dave F.
     
    Dave F., Jul 21, 2004
    #2
  3. Dave F.

    TomD Guest

    I was afraid that was what you were after, but thought, "No, surely noone is
    that ambitious".

    Serioulsy, though, I'm not sure. I thought I remembered seeing one of the
    regulars here had a class that gave you that functionality, but I can't say
    that is a fact. If not, maybe try passing lisp to the command line and
    store it in a USER variable, as recently discussed here. That's the only
    thing I can think of.

    Please re-post if you find a way to directly read the DXF code values.
     
    TomD, Jul 21, 2004
    #3
  4.  
    Paul Richardson, Jul 21, 2004
    #4
  5. If you know starting angle of the lines that make up the Pattern...ie ANSI
    all start with a 45 degree angle..using the Pattern angle you can now deduce
    the angle of the line in the XY plane.

    Paul
     
    Paul Richardson, Jul 21, 2004
    #5
  6. Dave F.

    MP Guest

    just an idea, don't know if actually possible

    get the hatch pattern
    find the .pat file
    read the definition
    figure out the angle (somehow?)
    adjust according to the pattern angle
    ???
     
    MP, Jul 21, 2004
    #6
  7. Tom,

    If you need to create a list of constants for the line angle of each
    pattern...write a separate mod that will insert pattern at a Zero angle into
    empty dwg, explode, check angle of line element, write to txt file, erase
    lines, and next pattern... writing this mod will be quicker than doing
    manually.

    write to text file in useable format that you can cut and paste into VBA..

    Dim ANSI31 As Variant: ANSI31 = 0.785398
    Dim ANSI32 As Variant: ANSI32 = 0.785398

    you could also store these values as a txt file and find as necessary. that
    way users can update file without needing to see code... AfraLisp has a good
    example on using txt files parametrically.

    Good Luck,

    Paul
     
    Paul Richardson, Jul 21, 2004
    #7
  8. even eaiser... just iterate the .pat file. no need to use acad at all. All
    patterns start with * which can be used as a pointer to find each pattern,
    next line in .Pat contains the entity angle, so does the next if there is
    more than one entity in the pattern.
     
    Paul Richardson, Jul 21, 2004
    #8
  9. Dave F.

    Dave F. Guest

    That's certainly worth considering if I can't get the DXF directly.
    I wonder if the .pat definition is stored in within the .dwg once it's used?

    Cheers
    Dave F.
     
    Dave F., Jul 21, 2004
    #9
  10. Dave F.

    Dave F. Guest

    Unfortunately I want to select the line on the fly.
    & I use custom patterns with complicated lines

    Cheers anyway.
     
    Dave F., Jul 21, 2004
    #10
  11. Dave F.

    Dave F. Guest

    Thanks to all for replying

    I need to select the line interactively to get the angle so I can rotate a
    piece of text so that they're aligned.

    Cheers
    Dave F.
     
    Dave F., Jul 21, 2004
    #11
  12. Dave F.

    MP Guest

    then like someone else said, explode the pat into an array
    get the object corresponding to your pick point
    read the angle of that object
    erase the array of hatch stuff
     
    MP, Jul 21, 2004
    #12
  13. have user select hatch, and then compare the Pattern angle aganist the angle
    of the entities that make up the line. Ansi31 @ a 45 degree would be a 90
    degree line.
     
    Paul Richardson, Jul 21, 2004
    #13
  14. Dave F.

    Dave F. Guest

    That, unfortunately, requires knowledge of the lines angle before writing
    the routine.
    I have many complicated hatches with multiple lines all at different angles.

    Thanks
    Dave F.
     
    Dave F., Jul 22, 2004
    #14
  15. Dave you need to create a list of the hatch angles. Simple just iterate your
    ..PAT file look for the * which prefaces the name of the file, next line is
    the angle. see http://www.afralisp.com/vba/extext.htm for a great example of
    manipulating txt files.

    Paul
     
    Paul Richardson, Jul 22, 2004
    #15
  16. Dave F.

    TomD Guest

    But how in the world does this give him the angle of a specific line in the
    hatch? If there are lines of more than one angle in the pattern, there are
    multiple answers.
     
    TomD, Jul 22, 2004
    #16
  17. Dave F.

    MP Guest

    Thats why you'll maybe want to consider the other idea of exploding the
    hatch and reading the resultant object instead.
    I haven't seen you comment on that suggestion yet.
     
    MP, Jul 22, 2004
    #17
  18. read my other posts. said it a few times

     
    Paul Richardson, Jul 22, 2004
    #18
  19. also...just prompt the user with the multiple angles that make up the hatch
    and ask which one they want..
     
    Paul Richardson, Jul 22, 2004
    #19
  20. Dave F.

    Dave F. Guest

    It's a bit messy, isn't it?

    There a lot to go wrong. thought of exploded hatch lines fills me with
    dread.
    How would you get exploded entities into an array?

    I'm hoping someone will reply to my message above asking for a couple of
    routines from Frank Oquendo's site which may help me out.

    Dave F.
     
    Dave F., Jul 22, 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.