TheSwamp
Code Red => VB(A) => Topic started by: ELOQUINTET on August 23, 2007, 05:01:39 PM
-
Hello all,
I am looking for a way to insure that the plotstamp is always on when i print or publish drawings. I was looking in here and found a post which has this bit of code. I kinda understand it but also need to include the publish command and am not sure how to implement it?
Private Sub AcadDocument_BeginPlot(ByVal DrawingName As String)
ThisDrawing.SendCommand ("-plotstamp" & vbCr & "on" & vbCr & vbCr)
End Sub
-
You can change it thru the registry prior to printing/plotting/publishing.
It's located here: HKCU\Software\Autodesk\.......\Profiles\<Your Profile Name>\Dialogs\PlotStamp
Change the PlotStamp setting to 1 to turn it on; 0 will turn it off.
-
ummmm and how would i incorporate this into a routine that runs when the plot or publish event happens. I know how to turn it on but want to not have to worry about turning it on. I want it to always be on.
-
To do it using VBA will take more code than using LSP, so with that said, I offer up this little bit o' code that you can add into the ACAD.lsp file which will set the value to 1 (on) every time you start AutoCAD.
(vl-load-com)
(vl-registry-write (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "cprofile") "\\Dialogs\\Plot Stamp\\") "PlotStamp" 1)
And that's all you need.
-
It's located here: HKCU\Software\Autodesk\.......\Profiles\<Your Profile Name>\Dialogs\PlotStamp
How did you find that? I was looking thru the registry for just such a setting, and I could find the plotstamp stuff, but not the ON/OFF setting?
-
It's located here: HKCU\Software\Autodesk\.......\Profiles\<Your Profile Name>\Dialogs\PlotStamp
How did you find that? I was looking thru the registry for just such a setting, and I could find the plotstamp stuff, but not the ON/OFF setting?
I have my ways! :wink:
I just did a search for PLOTSTAMP and when I saw the REG_DWORD setting, I figured I was on to something. So I turned on the plot stamp, jumped back to the registry, refreshed it, and yup! The setting changed from 0 to 1.
-
I guess I gave up too soon :-( That was just what I was looking for. Since we now know where it is, I have a VBA solution if anybody is interested
-
I guess I gave up too soon :-( That was just what I was looking for. Since we now know where it is, I have a VBA solution if anybody is interested
Are you using a registry class to change the settings or do you have a reference to some file? Just curious.
-
This is the registry code I have for creating custom keys. It could be modified to change that plot stamp key as well. I got the profile name, but haven't found the version key yet. As soon as I get that, I can update that key as well. Anyway, here is my reg code
Sub Create3dTepRegValues() ' Must add reference to Windows Script Host Object Model
Dim scrpt As New WshShell
Dim DataVal As String
Dim regKey As String
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\VoltageClass"
scrpt.RegWrite regKey, 138
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\InsulatorType"
scrpt.RegWrite regKey, 1
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\ConnectionType"
scrpt.RegWrite regKey, 1
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\HighBus"
scrpt.RegWrite regKey, 162
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\LowBus"
scrpt.RegWrite regKey, 90
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\BusHighLow"
scrpt.RegWrite regKey, 1
regKey = "HKEY_CURRENT_USER\Software\Autodesk\Tep3D\PhaseSpacing"
scrpt.RegWrite regKey, 120
End Sub
Function getRegVal(DataVal As String) As String
Dim scrpt As New WshShell
getRegVal = scrpt.RegRead(DataVal)
End Function
Function setRegVal(regKey As String, DataVal As String) As String
Dim scrpt As New WshShell
scrpt.RegWrite regKey, DataVal
End Function
The last 2 functions are my GET/SET functions I can call from other modules
-
Are you using a registry class to change the settings or do you have a reference to some file? Just curious.
Must add reference to Windows Script Host Object Model
On a side note, your (vlax-product-key) is what I need for the VBA solution.
-
Are you using a registry class to change the settings or do you have a reference to some file? Just curious.
Must add reference to Windows Script Host Object Model
Yeah... that's much better than the lines upon lines of code needed for the registry class.
Have you used the VLAX.cls from Frank O? It works pretty good for evaluating LSP expressions from VBA.
Public Sub Vlax_Product_Key()
Dim obj As VLAX
Dim Key As String
Dim Prof As String
Set obj = New VLAX
Key = obj.EvalLispExpression("(vlax-product-key)")
Prof = obj.EvalLispExpression("(getvar ""cprofile"")")
Debug.Print "HKEY_CURRENT_USER\" & Key & "\Profiles\" & Prof & "\Dialogs\Plot Stamp\PlotStamp"
End Sub
-
Have you used the VLAX.cls from Frank O?
no, I never really learned VLisp enough to use the vl stuff in lisp, so I never explored it in VBA. Where does one get it?
-
The file I posted in the previous reply has it.
-
hey guys wow you've been busy. i already have some code in our acad.lsp
(command "-plotstamp" "on" "")
to turn it on but i am looking for a more fool proof way so if it gets turned off during a session when the user plots it gets turned back on. I thought i could do this by adding this to the plot and publish buttons which i use but my boss says that sometimes she uses these but other times she types plot in which case it doesn't turn it on. That's why i was thinking it would be a better route to go the event route wherein if plot or publish commands are issued the plotstamp is turned on. do you understand what i'm wanting now?
-
Okay... Here you go. Using Duh's idea of the WshShell (which you'll need to add a reference to) and VLAX.cls here's what I came up with. The attached file has everything you need.
Option Explicit
Public strPlotStampLocale As String
Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Dim oWsh As WshShell
GetPlotStampLocation
Select Case UCase(CommandName)
Case Is = "PUBLISH"
Set oWsh = New WshShell
oWsh.RegWrite strPlotStampLocale, "1", "REG_DWORD"
Set oWsh = Nothing
Case Is = "PLOT"
Set oWsh = New WshShell
oWsh.RegWrite strPlotStampLocale, "1", "REG_DWORD"
Set oWsh = Nothing
End Select
End Sub
Private Sub GetPlotStampLocation()
Dim obj As VLAX
Dim Key As String
Dim Prof As String
Set obj = New VLAX
Key = obj.EvalLispExpression("(vlax-product-key)")
Prof = obj.EvalLispExpression("(getvar ""cprofile"")")
strPlotStampLocale = "HKEY_CURRENT_USER\" & Key & "\Profiles\" & Prof & "\Dialogs\Plot Stamp\PlotStamp"
End Sub
-
matt,
first of all thank you for helping me out. i have a couple of questions.
1 refresh my memory on how i add a reference to wshshell
2 would it be possible to also incorporate a regen when plotting and a regen and qsave when publishing.
we actually have a traditional plotstamp and a filename stamp which is rtext and requires a regen. the qsave in the publish is so we there won't be any unsaved changes which would prevent us from saving the dsd file. i have this built into our buttons but would like to fool proof this process too.
Is this possible?
-
matt,
first of all thank you for helping me out.
No problem. You're welcome.
1 refresh my memory on how i add a reference to wshshell
Tools --> References
2 would it be possible to also incorporate a regen when plotting and a regen and qsave when publishing.
we actually have a traditional plotstamp and a filename stamp which is rtext and requires a regen. the qsave in the publish is so we there won't be any unsaved changes which would prevent us from saving the dsd file. i have this built into our buttons but would like to fool proof this process too.
Is this possible?
RTEXT is history....Use FIELDS instead. There are options you can set that determine whey they get updated.
-
Matt i have both of them loaded but when i try to add a reference to WshShell it does not appear in the list? All I see under WSH is wshcontrollerlibrary is this it?
I tried using fields for this but found that it did not always update but rtext did so I used that. I don't recall exactly what the problem was so maybe I will have to revisit that when I have more time. Now I'm most concerned with the plotstamp.
-
Matt i have both of them loaded but when i try to add a reference to WshShell it does not appear in the list? All I see under WSH is wshcontrollerlibrary is this it?
I tried using fields for this but found that it did not always update but rtext did so I used that. I don't recall exactly what the problem was so maybe I will have to revisit that when I have more time. Now I'm most concerned with the plotstamp.
Both of WHAT loaded?? The DVB I posted already has a reference to WshShell (it shows up at the top of the list, already checked).
-
yes i kinda figured it out on my own that WSH was an abbreviation for Windows Script Host. Forgive me I'm a novice but when you said I needed to add something you neglected to tell me that you already added it :| It appears to be working just as I wanted it to so thank you very much sir. I will have to try to reproduce my Fields problem and report it to you but this will have to wait until monday as I have something else to do today. Thanks again
-
You're welcome. Glad you got it working.
-
Hey guys I just got a new computer in our department and the vba routine I had running to insure the plotstamp is updated upon printing is now giving me an error upon startup. When I click on debug it highlights this line:
Set obj = New VLAX
Do I need to put some files on this new computer to get it to work?
-
i think i figured out the problem. the new computer only has office 2002 whereas others have 2003 and the excel 11.0 is missing from the references. so is there anyway i can make it work across multiple versions or no?
-
there is a way, but I dont know how to do it. I think Bob knows how. I vaguely remember him doing something like that
-
Wasn't my problem so I don't remember what I came up with, although I somewhat remember it happening. It seems like it was here though so a search might turn it up.
-
I got them to update the office and it works now. I was more curious than anything to see if it is possible.
-
You don't need to add a reference to excell to use it.
Late bind it like below.
Dim Excel As Object
'Dim Excel As Excel.Application
Dim ExcelWorkbook As Object
'Dim ExcelWorkbook As Workbook
Dim ExcelSheet As Object
'Dim ExcelSheet As WorkSheet
The bad part is intellisense doesn't work and latebinding is very slow.
I couldn't find a way to uncheck a wrong reference (say 2003 on the 2002) programmatically, so the late binding is the easiest way to handle multi -versions