PDA

View Full Version : lines and stuff....


solarBreeze
08-09-2004, 02:11 PM
hello everyone
I posted this somewhere else and I've just realised that this is a better place to post it. I hope that someone can help me


I am currently pulling my hair :shock: out, trying to work with XData. (Extended Data) using VBA only :shock: (lisp looks even worse!)

I would like to add data to lines in a drawing, and when I open a form, I would like to list all the Xdata for each line in a listbox.

I can add the data, and read it individually, but I have no idea how to go through each line, and read it's X-data
It sounds simple I know, but I can't work out how to do it!!

does anyone have any ideas?

thanks





This function works :D and allows me to enter the Xdata for a line:


Sub AddXData()

Dim util As Object
Set util = ThisDrawing.Utility

Dim anObj As Object
Dim pt As Variant
On Error Resume Next

util.GetEntity anObj, pt, "Select an entity: "
Set util = Nothing

Dim xdataType As Variant
Dim xdataValue As Variant
Dim appName As String
appName = "LINEDATA"
anObj.GetXData appName, xdataType, xdataValue
If ("Empty" = TypeName(xdataType)) Then
Dim tmp(0 To 0) As Integer
xdataType = tmp
ReDim xdataValue(0 To 0)


xdataType(0) = 1001
xdataValue(0) = "LINEDATA"
End If


Dim strinput, strinput2 As String



With ThisDrawing.Utility
.InitializeUserInput 1, "10 20 30 40 50"

strinput = .GetKeyword(vbCr & "CABLE TYPE [10/20/30/40/50]: ")
strinput2 = InputBox("Enter the length of this cable. If you would prefer to do this later, enter 'no'")



End With

xdataType(0) = 1000
xdataValue(0) = strinput2

xdataType(1) = 1000
xdataValue(1) = strinput


anObj.SetXData xdataType, xdataValue

End Sub


I would like to be able to go through each line and list its XData
I've tryed to do it like this


For Each AcadLine In ThisDrawing.ModelSpace

If element.EntityType = AcadLine Then
Set lines = AcadLine


lines.GetXData "LINEDATA", xdataType, xdataValue (????)

[some kind of code to output data to listbox here]

Next




what a pain in the neck!!! :shock:

Eddie
09-09-2004, 12:08 PM
Try something like this.

For Each AcadLine In ThisDrawing.ModelSpace

If element.EntityType = AcadLine Then
Set lines = AcadLine

AcadLine.GetXData "LINEDATA", xdataType, xdataValue
If ("Empty" = TypeName(xdataType)) Then
Dim tmp(0 To 0) As Integer
xdataType = tmp
ReDim xdataValue(0 To 0)

xdataType(0) = 1001
xdataValue(0) = "LINEDATA"
End If

form.list(index) = xdatavalue(0)

Next
Where "index" would be the line number in the listbox
I have a module that does something similar, I'll post some of that code if you wish.

solarBreeze
09-09-2004, 12:21 PM
thanks a lot - that's cool!
:D