Author Topic: Picking one object in selection set..  (Read 2237 times)

0 Members and 1 Guest are viewing this topic.

hardwired

  • Guest
Picking one object in selection set..
« on: March 03, 2008, 11:28:43 AM »
Hi,

I know this must be simple but can i code a selection set to only pick ONE object?

I'm using the SelectOnScreen method but I can pick lots of object, and I just want to force it to ONE..

I have this code:

Code: [Select]
Private Sub blockpick1BTN_Click()
FixingsChartFRM.Hide
On Error Resume Next
ThisDrawing.SelectionSets.Delete ("FiX_SS")
Set SS = ThisDrawing.SelectionSets.Add("FiX_SS")

Dim Ftype(0) As Integer
Dim FData(0) As Variant

Ftype(0) = 2
FData(0) = "AcDbBlockReference"

On Error Resume Next
SS.SelectOnScreen Ftype, FData
FixingsChartFRM.Show
End Sub


....1: It won't show any blocks that i have picked (command line says Select Objects: 0 Found) and:
2: Is there a better way to add the object to the selection set than this anyway?

Chuck Gabriel

  • Guest
Re: Picking one object in selection set..
« Reply #1 on: March 03, 2008, 11:31:27 AM »
The GetEntity method of the Utility class will only let you select a single entity.

Atook

  • Swamp Rat
  • Posts: 1030
  • AKA Tim
Re: Picking one object in selection set..
« Reply #2 on: March 03, 2008, 11:48:51 AM »
Bonus of the GetEntity is that you don't need a selectionset anymore, and just work directly with the entity. You need to check that the entity is the right type though, invariably your user will pick a polyline when you're expecting a block.. :)

hardwired

  • Guest
Re: Picking one object in selection set..
« Reply #3 on: March 04, 2008, 04:28:18 AM »
Hi,

Thanks both of you, yeah forgot about GetEntity. Whats the best way to check that the object is a block?

hardwired

  • Guest
Re: Picking one object in selection set..
« Reply #4 on: March 04, 2008, 04:45:26 AM »
Sorry, i worked that out but one more thing....

....I want to put the name of the block name in a textbox on the userform, but there is only ObjectName for an AcadObject, how can i get the block name from the selected object...


This is the crude code i'm using after the GetEntity part:

Code: [Select]
ThisDrawing.Utility.GetEntity FixBlock, PickPoint, "Select a fixing.."

If FixBlock.ObjectName = "AcDbBlockReference" Then
    fx1descTXT.Text = FixBlock.ObjectName
    FixingsChartFRM.Show
ElseIf FixBlock.ObjectName <> "AcDbBlockReference" Then
    MsgBox "Please pick a block.."
    GoTo PICK
End If


Arizona

  • Guest
Re: Picking one object in selection set..
« Reply #5 on: March 04, 2008, 05:57:01 AM »
fixblock.name = "your text"

hardwired

  • Guest
Re: Picking one object in selection set..
« Reply #6 on: March 04, 2008, 06:14:51 AM »
oh right, simple as that, lol. I didn't think there was a Name property for an AcadObject as it didn't come up in the intellisense list. Thanks :)

Chuck Gabriel

  • Guest
Re: Picking one object in selection set..
« Reply #7 on: March 04, 2008, 07:16:09 AM »
Here is another way to ensure the user selects a block:

Code: [Select]
Private Const ERR_TYPE_MISMATCH As Long = 13
Private Const ERR_MISSED_PICK As Long = -2147352567

Sub test

  On Error GoTo ERROR_HANDLER

  Dim blockRef As AcadBlockReference
  Dim varPt As Variant
  ThisDrawing.Utility.GetEntity blockRef , varPt, "Select a block: "

  Exit Sub
 
ERROR_HANDLER:
  Select Case Err
    Case ERR_TYPE_MISMATCH
      ThisDrawing.Utility.Prompt "You may only select a block: "
      Resume
    Case ERR_MISSED_PICK
      ThisDrawing.Utility.Prompt "You missed: "
      Resume
    Case Else
      Err.Raise Err.Number, Err.Source, Err.Description, Err.HelpFile, Err.HelpContext
  End Select
 
End Sub
« Last Edit: March 04, 2008, 07:20:55 AM by Chuck Gabriel »