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

0 Members and 2 Guests are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
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.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
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.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
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.

Glenn R

  • Guest
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

Jeff_M

  • King Gator
  • Posts: 4087
  • 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

  • Guest
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 :)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
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.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
Re: what space am i?
« Reply #7 on: July 18, 2008, 02:38:17 PM »
No probs Duh.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
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.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

SEANT

  • Bull Frog
  • Posts: 345
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

  • Guest
Re: what space am i?
« Reply #10 on: July 18, 2008, 06:53:38 PM »
Correct.

Bryco

  • Water Moccasin
  • Posts: 1882
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")

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
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.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
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.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Glenn R

  • Guest
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?