.NET

Reply
Contributor
Posts: 20
Registered: ‎11-06-2008
Message 1 of 7 (904 Views)
Accepted Solution

Cannoscale formatting

904 Views, 6 Replies
10-21-2010 03:24 PM

Dim str As String = ("1/16""" & " = 1'-0""")

MsgBox("Cannoscale = " & CannoScale)
Application.SetSystemVariable("CANNOSCALE", str)

 

I am new to learning vb.net. This problem will make that readily apparent :smileytongue: What is wrong with this statement? I have checked the output of str with a msgbox and it looks exactly like what I should be feeding the cannoscale system variable, yet it does not change the value. What could I be formatting incorrectly? I have it currently working in vba using the following format:

("1/16" & Chr(34) & "=1'-0" & Chr(34))

but it fires a debug error in vb.net

Output to cannoscale should be --> 1/16" = 1'-0"

 

 

*Expert Elite*
chiefbraincloud
Posts: 750
Registered: ‎02-13-2008
Message 2 of 7 (894 Views)

Re: Cannoscale formatting

10-21-2010 04:43 PM in reply to: kemp77

I assume that for your testing purposes you know that the scale exists, right?

 

That said, I'm not sure why it would fail, but try something like this:

 

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ocm As ObjectContextManager = db.ObjectContextManager
Dim occ As ObjectContextCollection = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES")
Dim tstAnnoScale As AnnotationScale = occ.GetContext("1/16""" & " = 1'-0""")
If Not tstAnnoScale Is Nothing Then db.Cannoscale = tstAnnoScale

 

Similar code works for me, and this way, you can test the tstannoscale object to be sure it exists before trying to set it. 

 

Dave O.                                                                  Sig-Logos32.png
Valued Mentor
Posts: 372
Registered: ‎01-20-2010
Message 3 of 7 (892 Views)

Re: Cannoscale formatting

10-21-2010 05:01 PM in reply to: chiefbraincloud

Also if you are ever dealing with StandardScale property of a viewport use values in documentation

 

under Autodesk.AutoCAD.DatabaseServices.StandardScaleType Enumeration

 

not Viewport.StandardScale Property they use "is instead of and"

 

To clarify, for a ViewPort.StandardScale property use values listed in the docs for

Autodesk.AutoCAD.DatabaseServices.StandardScaleType Enumeration
See picture "is" "and"
1338iE51AEAF3AA21689A
You can also find your answers @ TheSwamp
Contributor
Posts: 20
Registered: ‎11-06-2008
Message 4 of 7 (855 Views)

Re: Cannoscale formatting

10-25-2010 05:42 PM in reply to: chiefbraincloud

Thanks for the help understanding this so far guys. But using this code all I get is an eLockViolation.

 

Autodesk.AutoCAD.Runtime.Exception: eLockViolation   at Autodesk.AutoCAD.DatabaseServices.Database.set_Cannoscale(AnnotationScale annotationScale)   at ClassLibrary1.DialogBoxForm.OKButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\kburgess.UDA-DOMAIN\my documents\visual studio 2010\Projects\ClassLibrary1\ClassLibrary1\DialogBoxForm.vb:line 86

 

What could be the culprit of this? I am not using a fancy modeless form, I have verified the string is valid, and yet I still can't seem to do this basic function.

 

I have tried: 

("1/16""" & " = 1'-0""")

"1/16""" & " = 1'-0"""

("1/16"" = 1" & Chr(39) & "-0""")

"1/16"" = 1" & Chr(39) & "-0"""

 

All to no avail.  ps did I mention I hate this web interface? LOL

 

*Expert Elite*
chiefbraincloud
Posts: 750
Registered: ‎02-13-2008
Message 5 of 7 (851 Views)

Re: Cannoscale formatting

10-25-2010 07:17 PM in reply to: kemp77

From your error message, I can tell that you are running the code from a form (evidentally modal, since you said not modeless), and that still means you should lock the document.  Try wrapping your code that accesses the database in the Click Event handler with something like this:

 

Using loc as ApplicationServices.DocumentLock = MdiActiveDocument.LockDocument

   'your code here

End Using

 

That should work, but If it doesn't, try wrapping the Form Show code with the document lock.

Dave O.                                                                  Sig-Logos32.png
Contributor
Posts: 20
Registered: ‎11-06-2008
Message 6 of 7 (829 Views)

Re: Cannoscale formatting

10-26-2010 12:05 PM in reply to: chiefbraincloud

I now see that without locking the document none of my strings were working. With it locked all of them behave as they should. Thanks for nudge in the proper direction I needed. 

*Expert Elite*
chiefbraincloud
Posts: 750
Registered: ‎02-13-2008
Message 7 of 7 (818 Views)

Re: Cannoscale formatting

10-26-2010 05:28 PM in reply to: kemp77

It was not the string format that was causing the failure.  It was that autocad had the document locked from changes.  The language may be a little misleading, but the best I can explain it is that when you create your document lock, you are telling autocad that you are about to make changes and therefore autocad should not allow anything but you to make changes until you are done.

Dave O.                                                                  Sig-Logos32.png

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community