Author Topic: Very First Routine Help  (Read 2162 times)

0 Members and 1 Guest are viewing this topic.

bchapman

  • Guest
Very First Routine Help
« on: January 27, 2013, 06:02:51 PM »
Okay... first...anyone know where I can find code samples for c#.  Like "setting system variables".

Second... this is my first shot... can you please tell me what I'm doing wrong (other than trying to skip all the learning steps and writing a code ... lol...)

Code: [Select]
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using System;

namespace Brians_Tools
{
    public class BriansTools
    {
        [CommandMethod("40")]
        public void Forty()
        {
            Application.SetSystemVariable("dimscale", 40);
        }
    }
}

Thanks everyone :)

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Very First Routine Help
« Reply #1 on: January 27, 2013, 07:12:28 PM »
What makes you think you are doing something wrong? Error message? Load error?

bchapman

  • Guest
Re: Very First Routine Help
« Reply #2 on: January 27, 2013, 08:29:52 PM »
Got the following during debug ((using civil 3d 2012 with Windows 7 and 64bit...if that even matters)

Command: 40
Unknown command "40".  Press F1 for help.
Command: (40)
; error: bad function: 40
----------------------------------------------
I have a feeling I'm not going to enjoy this lol.

Also, if I wanted to define multiple variables can I just keep stacking them like the following:

Application.SetSystemVariable("dimscale", 40);
Application.SetSystemVariable("someothervariable", 1);
Application.SetSystemVariable("someothervariable", 40);

Thanks!

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Very First Routine Help
« Reply #3 on: January 27, 2013, 08:37:49 PM »
Your add-in is not getting loaded correctly


Is that the only class with a CommandMethod attribute in it?


Not sure but might expect a double so for a literal you might have to use 40.0

bchapman

  • Guest
Re: Very First Routine Help
« Reply #4 on: January 27, 2013, 09:05:03 PM »
Thanks...it is the only one with teh CommandMethod.

I'll try the 40.0 but I think you're right... I don't think I loaded it right from startup. I have a 64 bit system... should I be using the Arx x64 inc folder or should the regular inc do?

Thanks!

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Very First Routine Help
« Reply #5 on: January 27, 2013, 09:11:23 PM »
Did you Netload your dll into Autocad? Your code works fine as is, btw.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Very First Routine Help
« Reply #6 on: January 27, 2013, 09:12:20 PM »
ARe you building it for either a 64 bit system or AnyCPU? If you set it to build for x86 it won't run on your 64 bit install.

bchapman

  • Guest
Re: Very First Routine Help
« Reply #7 on: January 27, 2013, 09:16:54 PM »
I'd like anyone to be able to use it.

I still need to learn the basics, how to bracketing system works...how to define a variable...will be going through all those steps but wanted to make something useful first other than a "Hello world"...that tutorial has always been useless to me lol.

I'll try to figure out where I screwed up... not sure what's going on, but now that I know the addin is written okay, I know where to look. Much appreciated

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Very First Routine Help
« Reply #8 on: January 27, 2013, 09:55:11 PM »
What is your Project set to build to?


bchapman

  • Guest
Re: Very First Routine Help
« Reply #9 on: January 27, 2013, 10:12:33 PM »
That particular drop down is empty :/

bchapman

  • Guest
Re: Very First Routine Help
« Reply #10 on: January 27, 2013, 10:26:44 PM »
Sorry for waisting your time guys... I'll try to troubleshoot this stuff more.  I had the code in the "plugin" in my solutions explorer. It was supposed to be in "myCommmands.cs"

Can't help but be a little more excited about learning it... hate that...keeps me up all the time lol

Thanks!
« Last Edit: January 27, 2013, 10:43:28 PM by BC_in_NV »