TheSwamp
Code Red => VB(A) => Topic started by: viva on September 19, 2006, 05:20:47 AM
-
hi everybody,
iam a newbee in vba. iam having doubts in VBA. after running the program, i want 2 check the result whether its working or not. After running the lisp , v can use ! variable for check the result. but i dont know how 2 check . can anyone help me.
Dim ssetObj As AcadSelectionSet
Dim mode As Integer
Dim grpCode(1) As Integer
Dim dataVal(1) As Variant
Set ssetObj = ThisDrawing.SelectionSets.Add("SS01") --- why they had add "SSO1".
mode = acSelectionSetAll
grpCode(0) = 0
dataVal(0) = "LWPOLYLINE"
grpCode(2) = 8
dataVal(2) = "route"
ssetObj.Select mode, , , grpCode, dataVal
'ssetObj.Erase
'ssetObj.Delete
Edit - code tags added
-
You can run the IDE in debug mode and "watch" the variables, the same as you can in the Visual Lisp IDE.
-
For what you are trying to do, here is a good starting place. The code below moves all blocks to layer 0. It first looks to see if a selection set of that name exists and deletes it if it does. It then creates the Selection set of all entities then filters based on type. It then moves these entities to zero layer and deletes the selection set.
Hope this helps...
Option Explicit
Public Sub TestSet(objDoc As AcadDocument)
Dim objSelSet As AcadSelectionSet
Dim objSelCol As AcadSelectionSets
Dim objLayer As AcadLayer
Dim intType(0) As Integer
Dim varData(0) As Variant
Dim objEnt As AcadEntity
Set objSelCol = objDoc.SelectionSets
For Each objSelSet In objSelCol
If objSelSet.Name = "test1" Then
objSelSet.Delete
Exit For
End If
Next objSelSet
Set objSelSet = objSelCol.Add("test1")
intType(0) = 0
varData(0) = "INSERT"
objSelSet.Select 5, filtertype:=intType, _
filterdata:=varData
For Each objEnt In objSelSet
Set objLayer = objEnt.Layer
If Not objLayer.Freeze And objLayer.LayerOn Then
objEnt.Layer = 0
End If
Next objEnt
Set objSelCol = Nothing
objSelSet.Delete
End Sub
-
should that be
objEnt.Layer = "0"
? ?
-
Yes, you are right. It should be a string :-)
-
hi kerry and arizona,
thanks for ur reply. ur support give me some cofident in learning VBA.
Actually i had written lisp for collecting coordinates of the polylines and stored in list. the same thing i am trying through VBA.
In VBA, i had reached upto collecting the polylines thru selectionset. now i want 2 collect coordinates.
thanks for ur great support
regards
vivek
-
why they had add "SSO1".
This is just a name any name will do.
Use Arizona's selectionset test
For Each objSelSet In objSelCol
If objSelSet.Name = "test1" Then
objSelSet.Delete
Exit For
End If
Next objSelSet
fix your code- grpCode(2) is no good
ctrl+g will bring up your immediate window
Debug.Print will print to that
(or use the locals or watch window as Kerry was saying.
Add below.
Debug.Print ssetObj.count
ssetObj.Delete
ssetObj.Erase-will delete the items in the selectionset-you don't want that.
ssetObj.Delete-will delete the selectionset and not the items in it.
Now you can use a for loop to work with your plines.
Make a collection to add your coordinates.
Dim CoordCol As Collection
Set CoordCol = New Collection
now place your cursor after Collection and hit F1
this will take you to help