ATTOUT lisp routine from AUTOCAD to PROGECAD

#1
Hi,

I'm working on tool that export attributes from progecad to spreadhseet. My plan was to do it by VBA, but the command .getAttribute is much slower than the express tool attout. I would like to create a lisp routine that would call the attout and exported text file, i found this code which work in AUTOCAD, but not in progecad. Can anyone help me convert it to intellicad lisp? And also, Is there any good literature that could teach me basics of the intellicad lisp?

Thank you.

The error say:
error: LOAD failed
Command: _APPLOAD

Code: Select all

(defun c:out-att ()
(load "attout")
(setq fna (strcat (getvar "dwgprefix")
(acet-filename-path-remove (acet-filename-ext-remove (getvar "dwgname")))
".txt"
))
(setq ss (ssget "X" '((0 . "INSERT") (66 . 1))))
(bns_attout fna ss)
)

Re: ATTOUT lisp routine from AUTOCAD to PROGECAD

#6
Hi,
If you use VBA, please refer to this snippet:

Extract all attributes to a text file:

Code: Select all

Public Sub AttOut()
    Dim SSetCol As SelectionSets
    Dim sset As SelectionSet
    Dim BlkInsert As BlockInsert
    Dim BlkAtts As Variant
    
    
    Set SSetCol = ActiveDocument.SelectionSets
    For Each sset In SSetCol
        If sset.Name = "SS" Then
            ActiveDocument.SelectionSets.Item("SS").Delete
            Exit For
        End If
    Next
     
    Set sset = ActiveDocument.SelectionSets.Add("SS")
    Dim FilterType(0 To 1) As Integer
    Dim FilterData(0 To 1) As Variant
    FilterType(0) = 0: FilterData(0) = "INSERT"
    FilterType(1) = 66: FilterData(1) = "1"

    sset.SelectOnScreen FilterType, FilterData
    
   
    ' open a text file
    Dim filePath As String
    filePath = ActiveDocument.GetVariable("DwgPrefix")
    
    Set fso = New FileSystemObject
    Set txtFSO = fso.CreateTextFile(filePath & "\Attributes.txt", True, True)
    

    '  write the attributes into a text file
    For Each BlkInsert In sset
       Set BlkAtts = BlkInsert.GetAttributes
       
       txtFSO.WriteLine "BlockName: " & BlkInsert.Name
       For Each objAttrib In BlkAtts
            txtFSO.Write vbTab & "(" & objAttrib.TagString & " ; " & objAttrib.TextString & ")"
       Next
       
       txtFSO.WriteLine
    Next
        
    txtFSO.Close
           
End Sub
And set value for attributes:

Code: Select all

Public Sub SetAtts()
    Dim SSetCol As SelectionSets
    Dim sset As SelectionSet
    Dim BlkInsert As BlockInsert
    Dim BlkAtts As Variant
    
    ' tag value data, change here to fix your data (tagName _ tagValue)
    Dim tagValuesDict As New Scripting.Dictionary
    tagValuesDict.Add Key:="NAME-1", Item:="Tesla"
    tagValuesDict.Add Key:="DESCRIPTION-1", Item:="Automation"
    tagValuesDict.Add Key:="DESIGNED", Item:="Design name"
    tagValuesDict.Add Key:="DRAWN", Item:="Drawer name"
    
    
    Set SSetCol = ActiveDocument.SelectionSets
    For Each sset1 In SSetCol
        If sset1.Name = "SS" Then
            ActiveDocument.SelectionSets.Item("SS").Delete
            Exit For
        End If
    Next
     
    Set sset = ActiveDocument.SelectionSets.Add("SS")
    Dim FilterType(0 To 1) As Integer
    Dim FilterData(0 To 1) As Variant
    FilterType(0) = 0: FilterData(0) = "INSERT"
    FilterType(1) = 66: FilterData(1) = "1"

    sset.SelectOnScreen FilterType, FilterData
    
    For Each BlkInsert In sset
       Set BlkAtts = BlkInsert.GetAttributes
       For Each objAttrib In BlkAtts
        If tagValuesDict.Exists(objAttrib.TagString) Then
            '  set the attributes value
           objAttrib.TextString = tagValuesDict(objAttrib.TagString)
        End If
       Next
    Next
    
    ActiveDocument.Regen (vicActiveViewport)
        
End Sub