Author Topic: PlotOrigin Toggle  (Read 4252 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
PlotOrigin Toggle
« on: November 15, 2005, 10:59:14 AM »
So I'm starting to dabble with VB in AutoCAD.  Managed to modify some code to get the following that will center a layout.  Also made one to set the offset back.  I can't, however, figure out how to make it toggle with one button.  I'm assuming it's the = Not part that I need to modify, but I just don't know how to.  Once again, I'm too busy to read up on it right now, so I would appreciate any suggestions on how to make it toggle, criticism about the layout, or a general explanation about how you're feeling today.  Thank you for your time.  I love you all  :love:
Code: [Select]
Sub PlotCentered()

    Dim ACADLayout As ACADLayout
   
    Set ACADLayout = ThisDrawing.ActiveLayout

    ACADLayout.CenterPlot = Not ACADLayout.CenterPlot

    ThisDrawing.Regen acAllViewports
End Sub

Sub PlotOffset()

    Dim ACADLayout As ACADLayout
    Dim newValue(0 To 1) As Double
   
    Set ACADLayout = ThisDrawing.ActiveLayout

    newValue(0) = 0
    newValue(1) = 64.516
    ACADLayout.PlotOrigin = newValue

    ThisDrawing.Regen acAllViewports
End Sub

deegeecees

  • Guest
Re: PlotOrigin Toggle
« Reply #1 on: November 15, 2005, 11:05:52 AM »
Boolean comes to mind.

How bout an "IF" statement.

Pseudo Code:

If that

Then this

Else this

End If

Bob Wahr

  • Guest
Re: PlotOrigin Toggle
« Reply #2 on: November 15, 2005, 11:10:03 AM »
yeah, that's what I was thinking.  Something like
Code: [Select]
Sub PlotCenteredOrNot()

    Dim objLayout As ACADLayout
   
    Set objLayout = ThisDrawing.ActiveLayout

    If objLayout.CenterPlot = False Then
        objLayout.CenterPlot = True
    Else
        newValue(0) = 0
        newValue(1) = 64.516
        objLayout.PlotOrigin = newValue
    End If
    ThisDrawing.Regen acAllViewports
End Sub

Is that what you're after?

OK, now for the criticism, or at least the critique, okay a well meant pointer.  NEVER EVER FOR ANY REASON EVER should you dim something naming it the same as it's type.  Really, don't.

Arizona

  • Guest
Re: PlotOrigin Toggle
« Reply #3 on: November 15, 2005, 11:20:19 AM »
Bob,

You took the words right out of my mouth. However, Autodesk in their example does exactly the same thing. I was amazed!
Also you are right on with your statements.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #4 on: November 15, 2005, 11:26:16 AM »
Thank you very much everyone.  I will test out the new code at lunch time.  And yes, this code was from the help file.  Shame, shame AutoDesk!  :pissed:

Again, I'm JUST getting into this, so bear with me!

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #5 on: November 15, 2005, 11:36:15 AM »
Error message  :cry:


Bob Wahr

  • Guest
Re: PlotOrigin Toggle
« Reply #6 on: November 15, 2005, 11:41:17 AM »
doh!  Just add "Dim newValue(0 to 1) as double" in your declarations section.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #7 on: November 15, 2005, 11:50:55 AM »
SUCCESS!!!   8-)
Thank you everyone!!!

Code: [Select]
Sub PlotOriginToggle()

    Dim objLayout As ACADLayout
    Dim newValue(0 To 1) As Double
   
    Set objLayout = ThisDrawing.ActiveLayout

    If objLayout.CenterPlot = False Then
        objLayout.CenterPlot = True
    Else
        newValue(0) = 0
        newValue(1) = 64.516
        objLayout.PlotOrigin = newValue
    End If
    ThisDrawing.Regen acAllViewports
End Sub

deegeecees

  • Guest
Re: PlotOrigin Toggle
« Reply #8 on: November 15, 2005, 11:52:00 AM »
Glad I could help. When you making it out to Frankfort Dom?

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #9 on: November 15, 2005, 11:58:40 AM »
Glad I could help. When you making it out to Frankfort Dom?

I was out that way last night.  My girlfriend lives in Mokena.  My ex-girlfriend (before current) lives in Frankfort, and the one before her lives in Mokena...I must like 'em from that area!

deegeecees

  • Guest
Re: PlotOrigin Toggle
« Reply #10 on: November 15, 2005, 12:03:18 PM »
It is kinda backwoods out there, maybe there's something in the water.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #11 on: November 15, 2005, 12:10:09 PM »
It is kinda backwoods out there, maybe there's something in the water.

I know what you mean...

You probably know Morgan's & Thunderbowl...Used to manage the bowling alley and DJ in the bar...

deegeecees

  • Guest
Re: PlotOrigin Toggle
« Reply #12 on: November 15, 2005, 12:16:15 PM »
Very nice pool tables there, good atmosphere, but haven't been there in a couple years. Maybe this W/E get out there and school ya in some pool.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #13 on: November 15, 2005, 12:26:01 PM »
Very nice pool tables there, good atmosphere, but haven't been there in a couple years. Maybe this W/E get out there and school ya in some pool.

That's a possibility...but I must warn you...my dad owns a pool hall in Crestwood...

deegeecees

  • Guest
Re: PlotOrigin Toggle
« Reply #14 on: November 15, 2005, 12:31:35 PM »
Really? A good friend of mine just sold his, "Fast Break" billiards, in Crestwood. Hmmm, interesting.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: PlotOrigin Toggle
« Reply #15 on: November 15, 2005, 12:59:10 PM »
Really? A good friend of mine just sold his, "Fast Break" billiards, in Crestwood. Hmmm, interesting.

Yes...I do know of Fast Break...