anonymous block from a selection set?

anonymous block from a selection set?

Anonymous
Not applicable
401 Views
5 Replies
Message 1 of 6

anonymous block from a selection set?

Anonymous
Not applicable
Can someone show me how to make an anonymous block from a selection set?
thanks
0 Likes
402 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Sure, in a most basic form...not factoring in for UCS or any error
trapping.....

Sub testme()
Dim oBlk As AcadBlock
Dim oBlkRef As AcadBlockReference
Dim oSS As AcadSelectionSet
Dim varEnts() As AcadEntity
Dim I As Integer
Dim dPt(2) As Double

Set oSS = ThisDrawing.SelectionSets.Add("MyTestSS")
oSS.SelectOnScreen

If oSS.Count > 0 Then
ReDim varEnts(0 To oSS.Count - 1)
For I = 0 To oSS.Count - 1
Set varEnts(I) = oSS.Item(I)
Next
Set oBlk = ThisDrawing.Blocks.Add(dPt, "*U")
ThisDrawing.CopyObjects varEnts, oBlk
Set oBlkRef = ThisDrawing.ModelSpace.InsertBlock(dPt, oBlk.Name, 1, 1,
1, 0)
For I = 0 To oSS.Count - 1
oSS.Item(I).Delete
Next
End If
oSS.Delete
End Sub

"saidab" wrote in message news:5748615@discussion.autodesk.com...
Can someone show me how to make an anonymous block from a selection set?
thanks
0 Likes
Message 3 of 6

Anonymous
Not applicable
Still there is a problem, when adding the block here
Set oBlk = ThisDrawing.Blocks.Add(dPt, "*U")
I get this error:
"Calling method SetObjectId of Interface IAcadBaseObject failed".
But when I take the start out, it goes fine creating a static block,
then i use ConvertToAnonymousBlock to get the finel one,
Thank you for your help anyway.
0 Likes
Message 4 of 6

Anonymous
Not applicable
What I posted worked just fine for me in 2008 using VBA. If you are using another language could you post what it is you
used?

wrote in message news:5748819@discussion.autodesk.com...
Still there is a problem, when adding the block here
Set oBlk = ThisDrawing.Blocks.Add(dPt, "*U")
I get this error:
"Calling method SetObjectId of Interface IAcadBaseObject failed".
But when I take the start out, it goes fine creating a static block,
then i use ConvertToAnonymousBlock to get the finel one,
Thank you for your help anyway.
0 Likes
Message 5 of 6

Anonymous
Not applicable
I'm using 2007
Thanks
0 Likes
Message 6 of 6

Anonymous
Not applicable
Jeff,
FYI, this worked just fine for me in 2007 too

~'J'~
0 Likes