I have written program for selecting object but now I want to select last object automatically.
Is it down code is writeen is ok or some change in the Code.
Set LastObj = ThisDrawing.SelectionSets.Add(Count - 1)
pixlepark96@sancharnet.in
|
I have written program for selecting object but now I want to select last object automatically.
Is it down code is writeen is ok or some change in the Code.
Set LastObj = ThisDrawing.SelectionSets.Add(Count - 1)
pixlepark96@sancharnet.in
This will return the Last created object in the drawing, not necessarily the last item in the current layout.
HTHCode:Function LastObject() As AcadEntity Dim oLayout As AcadLayout Dim sLast As String Dim sHandle As String For Each oLayout In ThisDrawing.Layouts If oLayout.Block.Count > 0 Then sHandle = oLayout.Block.Item(oLayout.Block.Count - 1).Handle If CLng("&H" & sHandle) > CLng("&H" & sLast) Then sLast = sHandle End If Next If sLast > "" Then Set LastObject = ThisDrawing.HandleToObject(sLast) End Function
Jeff
Last edited by Jeff_M; 2006-04-06 at 04:42 PM.
Thanx
but in my object selection is not a block. I am selecting any last object
Try this-
hope this helps. Of course you will want to add your own code on to this, but I think that this is what you need.Code:Sub PickLast() Dim ss As AcadSelectionSet Set ss = ThisDrawing.SelectionSets.Add(Now) ss.Select acSelectionSetLast ;...your code here... End Sub
Cheers
HUH? All the code I posted does is search each Layout and get the most recently added object from each one and compares it to the previous one found. If the current one found is newer than the previous then it gets saved. This repeats until all layouts have been queried and the most recently added entity to the drawing is returned.Originally Posted by avinash00002002