TheSwamp
Code Red => VB(A) => Topic started by: Dommy2Hotty 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:
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
-
Boolean comes to mind.
How bout an "IF" statement.
Pseudo Code:
If that
Then this
Else this
End If
-
yeah, that's what I was thinking. Something like
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.
-
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.
-
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!
-
Error message :cry:
(http://home.comcast.net/~dominic.cesare/pictures/AutoCAD_PlotOriginToggle_Error.jpg)
-
doh! Just add "Dim newValue(0 to 1) as double" in your declarations section.
-
SUCCESS!!! 8-)
Thank you everyone!!!
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
-
Glad I could help. When you making it out to Frankfort Dom?
-
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!
-
It is kinda backwoods out there, maybe there's something in the water.
-
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...
-
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.
-
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...
(http://home.comcast.net/~dominic.cesare/pictures/Pockets_tables.JPG)
-
Really? A good friend of mine just sold his, "Fast Break" billiards, in Crestwood. Hmmm, interesting.
-
Really? A good friend of mine just sold his, "Fast Break" billiards, in Crestwood. Hmmm, interesting.
Yes...I do know of Fast Break...