Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
.NET
»
Topic:
Modify system variable on a closed drawing ?
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Modify system variable on a closed drawing ? (Read 1633 times)
0 Members and 1 Guest are viewing this topic.
latour_g
Newt
Posts: 184
Modify system variable on a closed drawing ?
«
on:
May 13, 2020, 10:26:54 AM »
Hi there,
I have done a few things on closed drawings but I have never changed a system variable, specificaly Proxygraphics. I have search to see if it's doable but found nothing.
So I'm asking here, is it doable to do so ?
Thnak you
«
Last Edit: May 14, 2020, 08:52:14 AM by latour_g
»
Logged
WOWENS
Newt
Posts: 59
Re: Modify system variable on a closed drawing ?
«
Reply #1 on:
May 27, 2020, 02:47:04 PM »
might give this a try
Code - vb.net:
[Select]
Private
Sub
test2
(
MyDwg
As
String
)
If
IsFileLocked
(
New
IO
.
FileInfo
(
MyDwg
)
)
=
False
Then
Using
db
As
New
Database
(
False
,
True
)
db
.
ReadDwgFile
(
MyDwg, IO
.
FileShare
.
ReadWrite
,
False
,
""
)
Dim
workDb
As
Database
=
HostApplicationServices
.
WorkingDatabase
If
HostApplicationServices
.
WorkingDatabase
<>
db
Then
HostApplicationServices
.
WorkingDatabase
=
db
End
If
Using
MyTrans
As
Transaction
=
db
.
TransactionManager
.
StartTransaction
(
)
Try
If
db
.
Orthomode
=
True
Then
db
.
Orthomode
=
False
Else
db
.
Orthomode
=
True
End
If
db
.
Saveproxygraphics
=
0
MyTrans
.
Commit
(
)
db
.
SaveAs
(
MyDwg, DwgVersion
.
Current
)
Catch
MyTrans
.
Abort
(
)
db
.
CloseInput
(
True
)
Application
.
DocumentManager
.
MdiActiveDocument
.
Editor
.
WriteMessage
(
vbCrLf
+
"Could Not Save Drawing "
&
MyDwg
)
Finally
If
HostApplicationServices
.
WorkingDatabase
<>
workDb
Then
HostApplicationServices
.
WorkingDatabase
=
workDb
End
If
End
Try
End
Using
db
.
Dispose
(
)
End
Using
Else
Application
.
DocumentManager
.
MdiActiveDocument
.
Editor
.
WriteMessage
(
vbCrLf
+
"Could Not Open Drawing "
&
MyDwg
)
End
If
End
Sub
Private
Function
IsFileLocked
(
ByVal
file
As
IO
.
FileInfo
)
As
Boolean
Dim
stream
As
IO
.
FileStream
=
Nothing
Try
stream
=
file
.
Open
(
IO
.
FileMode
.
Open
, IO
.
FileAccess
.
ReadWrite
, IO
.
FileShare
.
None
)
Catch
Return
True
End
Try
If
(
Not
(
stream
)
Is
Nothing
)
Then
stream
.
Close
(
)
End
If
Return
False
End
Function
EDIT (John): Added code tags.
«
Last Edit: May 27, 2020, 03:35:37 PM by John Kaul (Se7en)
»
Logged
Jeff H
Needs a day job
Posts: 6144
Re: Modify system variable on a closed drawing ?
«
Reply #2 on:
May 28, 2020, 01:43:33 PM »
As Wowens showed if is a variable stored in the drawing and should be a property of Database object then you will have to open it with ReadDwgFile.
For system wide variables you can edit with Application object or directly edit registry which probably would not be ideal.
Logged
--> Donate to TheSwamp <--
latour_g
Newt
Posts: 184
Re: Modify system variable on a closed drawing ?
«
Reply #3 on:
June 03, 2020, 03:00:23 PM »
Thanks to both of you ! I will try it soon and let you know i it'S work !
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
.NET
»
Topic:
Modify system variable on a closed drawing ?