Jump to content

How to install dotNet templates to visual studio


SOliver

Recommended Posts

Hi all

 

I've recently been having another attempt at installing the dotNet API for AutoCAD.

 

As my previous attempt I installed VS 2015 and the AutoCAD SDK. Once this is complete you are meant to open VS and select the templates from the list.

 

However, in all attempts the templates have not appeared in the New Project template lists for either vb vc# or c++.

 

There doesn't appear to be an opportunity for me to be making a mistake as the SDK is just a self extracting exe.

 

Is there a way for me to add these templates or does anyone have any idea of why they haven't turned up.

 

Note: The AutoDesk template sub label doesn't exist in my VS project templates list.

Link to comment
Share on other sites

  • 1 month later...

HI,

 

To get templates in VS2015 you need to install ObjectARX wizard

http://usa.autodesk.com/adsk/servlet/index?id=1911627&siteID=123112

 

I have also VS2015 and AutoCAD 2015 and i downloaded ObjectARX2018 and works for me with VS2015 and AutoCAD 2015.

 

But when you creating new project its necessary to choose .NET Framework 4.6 and then AutoCAD 2018 CSharp plug-in will be shown.

 

 

f3b4if

 

 

With this code you can try if it's working.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;



[assembly: CommandClass(typeof(AutoCAD_CSharp_plug_in2.MyFirstProgram))]

namespace AutoCAD_CSharp_plug_in2
{
   class MyFirstProgram
   {
       [CommandMethod("AdskGreeting")]
       public void AdskGreeting()
       {
           // Get the current document and database, and start a transaction
           Document acDoc = Application.DocumentManager.MdiActiveDocument;
           Database acCurDb = acDoc.Database;

           // Starts a new transaction with the Transaction Manager
           using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
           {
               // Open the Block table record for read
               BlockTable acBlkTbl;
               acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                            OpenMode.ForRead) as BlockTable;

               // Open the Block table record Model space for write
               BlockTableRecord acBlkTblRec;
               acBlkTblRec = acTrans.GetObject(acBlkTbl[blockTableRecord.ModelSpace],
                                               OpenMode.ForWrite) as BlockTableRecord;

               /* Creates a new MText object and assigns it a location,
               text value and text style */
               using (MText objText = new MText())
               {
                   // Specify the insertion point of the MText object
                   objText.Location = new Autodesk.AutoCAD.Geometry.Point3d(2, 2, 0);

                   // Set the text string for the MText object
                   objText.Contents = "Greetings, Welcome to AutoCAD .NET";

                   // Set the text style for the MText object
                   objText.TextStyleId = acCurDb.Textstyle;

                   // Appends the new MText object to model space
                   acBlkTblRec.AppendEntity(objText);

                   // Appends to new MText object to the active transaction
                   acTrans.AddNewlyCreatedDBObject(objText, true);
               }

               // Saves the changes to the database and closes the transaction
               acTrans.Commit();
           }
       }

       [CommandMethod("_inputCoord")]


   }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...