Page 1 of 1
ATTOUT lisp routine from AUTOCAD to PROGECAD
Posted: Fri Oct 29, 2021 8:21 am
by prokopu.m@gmail.com
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
Posted: Mon Nov 01, 2021 8:27 pm
by QuanNguyen
Hi,
This could be a starting point:
https://www.dropbox.com/s/4nozctsxzljmo ... t.lsp?dl=0
(sorry, can not post a lisp code here now)
Regards.
Re: ATTOUT lisp routine from AUTOCAD to PROGECAD
Posted: Tue Nov 02, 2021 3:01 am
by prokopu.m@gmail.com
Thank you very much,
it does what i need, except it doesn't show the block handle. I'm surprised that even though it loop trough the blocks, it works really fast.
Should i understand to it, that there is no functionality in intelicad-lisp to call the command "attout" and the export has to be done "manualy"?
Re: ATTOUT lisp routine from AUTOCAD to PROGECAD
Posted: Tue Nov 02, 2021 3:59 am
by QuanNguyen
Yes, the IntelliCAD doesn't have the command same as the "attout" to export attribute to file.
But you can use the lisp functions or VBA to extract the attribute and block handle/name ...
Re: ATTOUT lisp routine from AUTOCAD to PROGECAD
Posted: Fri Nov 05, 2021 8:59 am
by prokopu.m@gmail.com
Thank you very much.
And if i would like to use substitue the attin command using VBA, do you know any other way how to do that diferently than via .getvariable? I think that's the slowest part of the data migration chain.
Re: ATTOUT lisp routine from AUTOCAD to PROGECAD
Posted: Sun Nov 07, 2021 10:11 pm
by QuanNguyen
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