Jump to content

VBA CODE ERROR / New collection problem..


classof

Recommended Posts

hello..

I am using "autocad2006".

I want to know the number of lines and length of lines drawn at "current layer".

But it didn't work properly. I don't know why.

Please help me about below code.

 

Sub LineSelect()

Dim mode As Integer

Dim retval As New Collection

Dim gpCode(0) As Integer

Dim dataValue(0) As Variant

Dim ssetObj As AcadSelectionSet

Dim tempent As AcadEntity

With ThisDrawing

gpCode(0) = 0: dataValue(0) = "LINE"

mode = acSelectionSetAll

On Error Resume Next

If .SelectionSets("SELECT") Then .SelectionSets("SELECT").Delete

On Error GoTo 0

Set ssetObj = .SelectionSets.Add("SELECT")

ssetObj.Select mode, , , gpCode, dataValue

Dim idBlock As Long

idBlock = ThisDrawing.ActiveLayout.Block.ObjectID

Dim i As Integer

For i = 0 To ssetObj.Count - 1

If ssetObj(i).OwnerID = idBlock Then

retval.Add tempent

End If

Next i

MsgBox retval.Count 'number of lines at current layout

 

Dim Eac As AcadLine

For Each Eac In retval

MsgBox Eac.Length 'ERROR

 

Next Eac

 

End With

End Sub

 

 

thank you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...