Author Topic: change cross hair size  (Read 6755 times)

0 Members and 1 Guest are viewing this topic.

WILL HATCH

  • Bull Frog
  • Posts: 450
Re: change cross hair size
« Reply #15 on: June 27, 2014, 12:55:10 PM »
I know Jeff already mentioned this, but I suspect it needs to me stated more literally. 

We can remove the reference to the interop assembly by using System.dynamic:

Code - C#: [Select]
  1. using System;
  2. using Autodesk.AutoCAD.Runtime;
  3. using Autodesk.AutoCAD.ApplicationServices;
  4.  
  5. [assembly: CommandClass(typeof(NEW_SET_PREFERENCES.Crosshairs))]
  6.  
  7. namespace NEW_SET_PREFERENCES
  8. {
  9.     public class Crosshairs
  10.     {
  11.  
  12.         [CommandMethod("PrefsSetCursor")]
  13.         public static void PrefsSetCursor()
  14.  
  15.         {  
  16.             dynamic acPrefComObj = Application.Preferences;
  17.             acPrefComObj.Display.CursorSize = 100;
  18.             acPrefComObj.Display.DisplayScrollBars = false;
  19.         }
  20.     }
  21. }
« Last Edit: June 27, 2014, 12:58:19 PM by WILL HATCH »

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: change cross hair size
« Reply #16 on: June 27, 2014, 07:27:14 PM »
Thanks for the clarification Will.  I understand what Jeff said about using references in a side project so you can get intellisense, etc and then dynamic in the main project so you don't have to do the references but other than the references what is the advantage of using COM if you can get the same thing from .Net?
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: change cross hair size
« Reply #17 on: June 27, 2014, 08:25:40 PM »
Keith,
I think the 'advantage' or otherwise is not considered by most people.
A lot of people will be 'translating" vb/vba/VLisp code .. so COM is the natural option.
The use of .NET for accessing System variables requires a bit of research , ie "is there a variable for this property ??"
The Interop (using intellisense) is reasonably transparent regarding what is available .. there is a getter/setter for the property .. using .NET for system variables requires knowledge that the variable exists.

As JONTHEPOPE indicated, using COM is the only easily available way in some cases.

That being said, I do believe .NET is faster and more economical, when it is available.
I s'pose the argument could be made that if 'we' need to have COM available for some properties is it really such a dis-advantage to use it for properties that are available in the .NET API.

edit:fixed some fat finger stuff
« Last Edit: June 28, 2014, 12:34:40 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Keith Brown

  • Swamp Rat
  • Posts: 601
Re: change cross hair size
« Reply #18 on: June 30, 2014, 03:15:10 PM »
Thanks for the info Kerry.


I didnt consider that scenario mainly because I was only introduced to Cad and Autodesk products a few years ago and never got involved in VBA or com.  It was always .net for me.


A question that I have is that if Autodesk is requesting that VBA projects be updated to .net solutions.  IF and that is probably a big if, but if VBA goes away in the future would COM go with it?  So any updating that is done with COM would have to be done again?  So i guess the question is if VBA is a product of COM or is COM a product of VBA or are they just two separate items that are not linked?
Keith Brown | AutoCAD MEP Blog | RSS Feed
AutoCAD MEP 2014 / Revit MEP 2014 / EastCoast CAD/CAM addon / Visual Studio 2013

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: change cross hair size
« Reply #19 on: June 30, 2014, 05:39:35 PM »
Hi Keith.

COM is independent of VBA, but is used by VBA and VB.
Com is also used by Visual Lisp, (Active-X).
I imagine it has a role in the new js API, but not sure.



kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JONTHEPOPE

  • Guest
Re: change cross hair size
« Reply #20 on: July 07, 2014, 02:51:45 PM »
So I added more lines in but I don't know if this is the best way to do it? is there a way That I am suppose to save the changes to the BlockTable record?

Code: [Select]
            dynamic acPrefComObj = Application.Preferences;
            acPrefComObj.Display.CursorSize = 100;
            acPrefComObj.Display.DisplayScrollBars = false;
            acPrefComObj.Files.QNewTemplateFile = ("C:/Users/dgladeau/AppData/Local/Autodesk/AutoCAD 2014/R19.1/enu/Template/9999 Wanye Gretzky");
            acPrefComObj.Files.AutoSavePath = ("C:/AcadTemp");
            acPrefComObj.System.EnableStartupDialog = false;

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: change cross hair size
« Reply #21 on: July 07, 2014, 11:08:36 PM »
So I added more lines in but I don't know if this is the best way to do it? is there a way That I am suppose to save the changes to the BlockTable record?

< .. >

What changes are you making to a BlockTable record ??

Exactly what are you trying to do ?

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JONTHEPOPE

  • Guest
Re: change cross hair size
« Reply #22 on: July 08, 2014, 12:49:23 AM »
Hi Kerry,

I'm not sure what I'm doing.
I put in a line for open and save but when I came back to work the next day my Qnew template setting was set to none.
I guess that I might need to apply my changes somehow so that the settings will stay changed, is this assumption right?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: change cross hair size
« Reply #23 on: July 08, 2014, 02:01:12 AM »
I don't have time to play with this at the moment.

I've never seen the need to do this sort of thing so I don't have experience with the issues you are having.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: change cross hair size
« Reply #24 on: July 08, 2014, 05:28:54 AM »
So I added more lines in but I don't know if this is the best way to do it? is there a way That I am suppose to save the changes to the BlockTable record?

Code: [Select]
            dynamic acPrefComObj = Application.Preferences;
            acPrefComObj.Display.CursorSize = 100;
            acPrefComObj.Display.DisplayScrollBars = false;
            acPrefComObj.Files.QNewTemplateFile = ("C:/Users/dgladeau/AppData/Local/Autodesk/AutoCAD 2014/R19.1/enu/Template/9999 Wanye Gretzky");
            acPrefComObj.Files.AutoSavePath = ("C:/AcadTemp");
            acPrefComObj.System.EnableStartupDialog = false;

Hi Kerry,

I'm not sure what I'm doing.
I put in a line for open and save but when I came back to work the next day my Qnew template setting was set to none.
I guess that I might need to apply my changes somehow so that the settings will stay changed, is this assumption right?

C:/Users/dgladeau/AppData/Local/Autodesk/AutoCAD 2014/R19.1/enu/Template/9999 Wanye Gretzky
Is not a valid template file.
The Preferences Files paths basically require string that is a valid folder path,  file path, or a for multiple values takes a string delimited  by ";".



Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: change cross hair size
« Reply #25 on: July 08, 2014, 06:32:35 AM »
... and, I just noticed : why are the strings in parenthesis ?

Jeff. The file string may be valid if the 9999 Wanye Gretzky is a .dwg or .dwt file.


Works for me ..

Code - C#: [Select]
  1.  
  2.             AcadPreferences acPrefComObj = (AcadPreferences) Application.Preferences;
  3.  
  4.             string templateFilePath = "c:/templates/Test space/cat - copy";  // <-- not on the safe list
  5.             acPrefComObj.Files.QNewTemplateFile = templateFilePath;
  6.  
  7.  
« Last Edit: July 08, 2014, 06:38:33 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: change cross hair size
« Reply #26 on: July 08, 2014, 07:14:48 AM »
... and, I just noticed : why are the strings in parenthesis ?

Jeff. The file string may be valid if the 9999 Wanye Gretzky is a .dwg or .dwt file.


Works for me ..

Code - C#: [Select]
  1.  
  2.             AcadPreferences acPrefComObj = (AcadPreferences) Application.Preferences;
  3.  
  4.             string templateFilePath = "c:/templates/Test space/cat - copy";  // <-- not on the safe list
  5.             acPrefComObj.Files.QNewTemplateFile = templateFilePath;
  6.  
  7.  
Ahhh,
assumed like a arse it had to have extension included and completely overlooked the  parenthesis.
Sorry about that, and thanks Kerry I could have wasted the pope's time.

JONTHEPOPE

  • Guest
Re: change cross hair size
« Reply #27 on: July 09, 2014, 02:02:17 PM »
Guys,

All my time is devoted to this site, the cult of hockey, and blu-ray discs.

I will never learn if I never fail.

Thanks again.