Author Topic: what space am i?  (Read 5757 times)

0 Members and 1 Guest are viewing this topic.

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
what space am i?
« on: July 17, 2008, 06:09:40 PM »
Off the top of my head, I cant remember how to determine if a block is in MS or PS.  Can someone remind me?  I thought it had somethinhg to do with OwnerID, but I can t find any code where I have used that, so Im not sure Im on the right track
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: what space am i?
« Reply #1 on: July 17, 2008, 06:25:20 PM »
nevermind, Bryco did it before and I just couldn't find it

Code: [Select]
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
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: what space am i?
« Reply #2 on: July 18, 2008, 06:45:08 AM »
A more betterer one perhaps? It demonstrates how to compare numbers (ObjectId's) rather than doing string comparisons:
Code: [Select]
Function IsPs(pBlkRef As AcadBlockReference) As Boolean
    IsPs = (pBlkRef.OwnerID <> ThisDrawing.ModelSpace.ObjectID)
End Function

Cheers,
Glenn.
Me

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: what space am i?
« Reply #3 on: July 18, 2008, 06:47:30 AM »
Actually, that should strictly be:

Code: [Select]
Function IsPs(pBlkRef As AcadBlockReference) As Boolean
    IsPs = (pBlkRef.OwnerID = ThisDrawing.PaperSpace.ObjectID)
End Function
Me

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: what space am i?
« Reply #4 on: July 18, 2008, 12:27:11 PM »
Glenn, I would think the first one more correct. "ThisDrawing.Paperspace" only refers to the most recently current Layout, so if the block is in any of the other Layouts the second method would still return False.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: what space am i?
« Reply #5 on: July 18, 2008, 01:04:35 PM »
Jeff,

Yeah, that's correct and only if this is being used in conjunction with a selectionset gathered from the user for instance. If you're processing inserts that are nested, all bets are off and neither of these would be correct anyway.

It shows the intent though :)
Me

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: what space am i?
« Reply #6 on: July 18, 2008, 02:25:03 PM »
Thanks Glenn, I like that much better.!
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: what space am i?
« Reply #7 on: July 18, 2008, 02:38:17 PM »
No probs Duh.
Me

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: what space am i?
« Reply #8 on: July 18, 2008, 05:19:06 PM »
Assuming
     
Code: [Select]
Set objBlkRef = getblock("UES")returns a block named UES, how can I check to see if it was returned?  I tried
Code: [Select]
If Not objBlkRef = Nothingwhich failed badly
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

SEANT

  • Bull Frog
  • Posts: 332
Re: what space am i?
« Reply #9 on: July 18, 2008, 06:26:26 PM »
Assuming
     
Code: [Select]
Set objBlkRef = getblock("UES")returns a block named UES, how can I check to see if it was returned?  I tried
Code: [Select]
If Not objBlkRef = Nothingwhich failed badly

I believe it should be:
If objBlkRef Is Nothing Then
Sean Tessier
AutoCAD 2016 Mechanical

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: what space am i?
« Reply #10 on: July 18, 2008, 06:53:38 PM »
Correct.
Me

Bryco

  • Water Moccasin
  • Posts: 1849
Re: what space am i?
« Reply #11 on: July 18, 2008, 07:26:34 PM »
I found it easier to make the getblock function a boolean.
If not getblock("UES") then goto InsertBlock
set b=thisdrawing.blocks("UES")

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: what space am i?
« Reply #12 on: July 21, 2008, 03:21:47 PM »
OK, I think I know what I need to do, but was wondering if there was a better way.  The code below checks what fonts are in the dwg, including fonts that came from Xrefs.  The quoted text below is in my text file "audit" of the dwg, and you can see the 3D-TTL-B| was consistently found to be wrong.  So I tried using a wildcard *| which also failed (I expected it to, but was hoping).  So I "think" I should use Instr() to check for the "|" character, and use the next char to the end of string for my check.  Is there a better way or am I on the right track?

Code: [Select]
      For Each objFont In ThisDrawing.TextStyles
            Select Case UCase(objFont.Name)
            Case "STANDARD"
            Case "*|STANDARD"  ' eval if xrefed
            Case "TEP"
            Case "TEP-TITLE"
            Case "TEP-TITLE 3-16"
            Case "TEP-TITLE 1-8"
            Case Else
                        MyFile.writeline vbTab & objFont.Name & vbTab & objFont.fontFile
                        KillDaFile = True
            End Select
      Next objFont
Quote
Non Standard Fonts:
   3D-TTL-B|Standard   Romans.shx
   3D-TTL-B|TEP   Romans.shx
   3D-TTL-B|arial   ARIALBD.TTF
   3D-TTL-B|UES   impact.TTF
   3D-TTL-B|TEP-TITLE   verdana.TTF
   3D-TTL-B|arial   ARIALBD.TTF
   3D-TTL-B|UES   impact.TTF


Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: what space am i?
« Reply #13 on: July 21, 2008, 03:22:25 PM »
BTW, Seant, you were spot on and it fixed my problem perfectly
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: what space am i?
« Reply #14 on: July 21, 2008, 03:30:20 PM »
Huh? We've gone from 'what space am I' to an 'audit' scenario....what exactly are you trying to do in the first place Duh?
Me