TheSwamp
Code Red => VB(A) => Topic started by: Kheilmann on June 01, 2006, 06:07:18 PM
-
Is there a way to find if a block is in model or paper space? I have dwgs that have a certain block mostly in layouts. I simply do a loop based on the # of blocks found..
For x = 0 to tempset.count -1
When each block is found it records the data for inserting a new one (ie. insertpt, scale, rotation, etc)
The problem is sometimes it finds a block in Mspace and inserts into Pspace or viceversa.
Does this make sense?
Any ideas?
Thanks in advance...
-
I looked at the properties of a block inserted in PS and MS, and couldn't see an active space (for lack of better word) property
-
Function IsPs(oBref As AcadBlockReference) As Boolean
Dim oblock As AcadBlock
Set oblock = ThisDrawing.ObjectIdToObject(oBref.OwnerID)
If Not oblock.Name = "*Model_Space" Then
IsPs = True
End If
End Function
-
Hint....the OWNER of an Entity is the Block of the Layout it resides in.....
Shoot, Bryco beat me to it.....but he doesn't address WHICH PS layout it's in..... :-)
-
they both beat me to it. Work jumped up in the middle of me testing it. Like Bryco, I didn't address which layout but what I had was
If objBlkRef.OwnerID = ThisDrawing.modelSpace.ObjectID Then
'It's modelspace
Else
'It's not
End if
-
I think this is better, alot faster.
Private lngMs As Long 'Put this in the declarations area
Function IsMsBlockref(lngOwner As Long) As Boolean
If lngMs = 0 Then
lngMs = ThisDrawing.ModelSpace.ObjectID
End If
If lngOwner = lngMs Then IsMsBlockref = True
End Function
Sub TestisModelSpace()
Dim SS As AcadSelectionSet
Dim i As Integer
Set SS = sset(0, "insert")
For i = 0 To SS.Count - 1
Debug.Print IsMsBlockref(SS(i).OwnerID), i, SS(i).Name
Next
End Sub
Edited as Bob's use of modelspace was better than a string search
-
Oh Baby call me Jerimiah, just noticed I'm over 200 posts.
Pretends to be Grid iron bloke, throws ball on ground and does a "Ministry of funny walks" walk.
-
This is how I go about replacing objects, oBlkRef is the block to be replaced:
Set oSpace = ThisDrawing.ObjectIdToObject(oBlkRef.OwnerID)
Set oNewBlk = oSpace.InsertBlock(insPt, Name, yada yada......)
'adjust properties to match original, or use them in the insertion code
Now I need not know anything else about the space I'm in.
-
Nice Jeff.
-
.......does a "Ministry of funny walks" walk.
Theres a Ministry of funny walks?
-
http://www.i-am-bored.com/bored_link.cfm?link_id=17189
-
Doh! I should have remembered that. :-D
-
Bob to the rescue, man that was good to watch again. A+ or is that c++