Author Topic: Selection Set Question  (Read 1834 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Selection Set Question
« on: February 23, 2005, 05:40:17 PM »
I can successfully create a Selection Set but I am trying to use the
Sset.Select acSelectionSetLast

To select the last entity inserted into my drawing, at the same time I would like to create a layer and place the inserted block onto that layer.

Any suggestions?

I appreciate it

Mark

Jeff_M

  • King Gator
  • Posts: 3942
  • C3D user & customizer
Selection Set Question
« Reply #1 on: February 23, 2005, 07:58:51 PM »
Mark, This code works for me to get the last VISIBLE created object:
Code: [Select]

Dim ss As AcadSelectionSet
Set ss = ThisDrawing.PickfirstSelectionSet

ss.Select acSelectionSetLast
Debug.Print ss.Item(0).ObjectName


To get the last created object in modelspace, regardless of visibility:
Code: [Select]

Dim ent As AcadEntity
Set ent = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)
Debug.Print ent.ObjectName

ML

  • Guest
Selection Set Question
« Reply #2 on: February 24, 2005, 09:07:46 AM »
Hey Jeff,

I really appreciate your help. I am not totally sure that you understood my question or may be I phrased it wrong.

I wanted use  Sset.Select acSelectionSetLast
acSelectionSetLast (according to the help screens) gets the last entity in the drawing and adds it to your selection set.

So, I wanted to grad the last inserted entity, then use VBA to place that entity on a specified layer.

That is really the code I am looking for, or an idea of how to make it happen.


Thanks again

Mark

ML

  • Guest
Selection Set Question
« Reply #3 on: February 24, 2005, 09:36:58 AM »
Hey Jeff

With you code example, It looks like I figured it out:

Thank you

Mark


Code: [Select]

Dim ss As AcadSelectionSet

Set ss = ThisDrawing.PickfirstSelectionSet

ss.Select acSelectionSetLast


Select Case ss.Item(0).ObjectName

Case Is = "AcDbBlockReference"
  ThisDrawing.Layers.Add ("Test")
  ss.Item(0).Layer = ("Test")
End Select