Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

List of Hatches in Bricscad

I have a routine for offsetting a 2d polyline (and then close itself) to be able to create a hatch area to represent a building.
I offer a dialogue of hatches to use, which in autocad 2019 is done with:
For Each hatchtype As drawing_windows.Data.HatchRibbonItem In drawing_windows.Data.HatchPatterns.Instance.AllPatterns
ComboBox_hatches.Items.Add(hatchtype)
Next
I cannot find how to gather all the names of all of the hatches in Bricscad.
Has anybody done this?
Cheers,
Jon

Answers

  • edited November 2018

    So, it turns out there is no internal storage of the patterns (available to us, anyway). You must scan the support folders for .pat files, then trawl through those, getting the names of each unique pattern.
    Here is a subset of my solution (I use VB).
    Imports vb = Microsoft.VisualBasic
    Module Module_get_hatch_patterns_bc
    Public Function get_hatch_patterns() As List(Of String)
    Dim list_of_patterns As New List(Of String)
    'Dim application_name As String = App.ActiveDocument.Application.FullName
    ' Dim currentDomain As AppDomain = AppDomain.CurrentDomain
    Dim SearchPath As String = App.ActiveDocument.GetVariable("ACADPREFIX")
    Dim SearchPaths() As String
    Dim surfNames As System.Collections.ObjectModel.ReadOnlyCollection(Of String)
    Dim projectName, pathName, extension, drawingName, ln As String
    Dim temp_string_array() As String
    SearchPaths = vb.Split(SearchPath, ";")
    For Each SearchPath In SearchPaths
    'SearchPath = SearchPath & "\UserDataCache\Support\en_US\"
    Try
    surfNames = My.Computer.FileSystem.GetFiles(SearchPath)
    For Each t As String In surfNames
    Call breakFileName(t, pathName, drawingName, extension)
    Select Case extension
    Case "pat"
    Try
    vb.FileOpen(1, t, Microsoft.VisualBasic.OpenMode.Input)
    While Not vb.EOF(1)
    ln = vb.LineInput(1)
    If vb.Left(ln, 1) = "
    " Then
    temp_string_array = vb.Split(ln, ",")
    ln = vb.Mid(temp_string_array(0), 2)
    If Not list_of_patterns.Contains(ln) Then
    list_of_patterns.Add(ln)
    End If
    End If
    End While
    Catch
    Finally
    vb.FileClose(1)
    End Try
    End Select
    Next
    Catch
    End Try
    Next
    If list_of_patterns.Count > 0 Then
    list_of_patterns.Sort()
    Return list_of_patterns
    Else
    Return Nothing
    End If
    End Function
    End Module

  • is it as simple as opening the hatch dialog and based on those names, type them into a text file?
    not exactly the most elegant back end way i guess, but seems like you'd only need to do it once...

Sign In or Register to comment.
Origami
Origami is the Japanese word for paper folding. ORI means to fold and KAMI means paper and involves the creation of paper forms usually entirely by folding.

Powered by VanillaForums, Designed by Steam