Wiki
Clone wikicad-via-powershell / Home
#readme.md
CAD via PowerShell
© Andrey Bushman, 2016
https://bitbucket.org/Andrey-Bushman/cad-via-powershell
##What is it?
CAD_via_PowerShell
is the example of PowerShell 4.0
hosting in AutoCAD 2016
. Also this project contains the examples
of the PowerShell scripts:
example-01.ps1
- this script draws the smiley in theModel
space of the current document. It is possible to create within AutoCAD session so many PowerShell hosts, how many will be required.example-02.ps1
- this script reads C# code of theexample.cs
file and launches it inside of AutoCAD.
You can see how does it work here.
It is possible to use this project code source for compiling for any
Teigha
-based application: nanoCAD, BricsCAD, etc (because Teigha contains
.NET API Classic).
##Is it really can be usefull?
PowerShell allows to do anything in the Windows and Windows domain. It can use all copabilities of COM, .NET, WMI, SharePoint, SQL Server, Remotes, etc (any tecnology and software by Microsoft and many other companies).
In my opinion, it is possible to use PowerShell instead of AutoLISP\Visual LISP in AutoCAD. PowerShell is more powerful than AutoLISP\Visual LISP. Autodesk doesn't develop own LISP many years. Microsoft permanently develops PowerShell. PowerShell is based on .NET. PowerShell is the main shell of experienced admin of Windows. Use of PowerShell allows to make anything. It can't be told about AutoLISP\Visual LISP.
So, if you know PowerShell, then you can write code for any (or for almost any) Windows application. PowerShell is is built-in into the modern versions of OS Windows (Win7 and newer).
I don't try to convert someone into "other religion" (it is not interesting for me). I only provide information for thought.
##System requirements
- Windows 7 or newer
- PowerShell 4.0 (you are to install Windows Management Framework 4.0)
- AutoCAD 2016
##Installing
Copy the acad.powershell.bundle
directory into any of these folders:
%APPDATA%/Autodesk/ApplicationPlugins\
%ProgramData%/Autodesk/ApplicationPlugins\
%ProgramFiles%/Autodesk/ApplicationPlugins
(is not recommended)
AutoCAD commands
PSHELL
- open PowerShell host (it has GUI for this example).
##NOTE
I am beginer in the PowerShell, therefore my code, for certain, can be rewritten more optimally by any experienced programmer. But my code is enough for the basic examples.
Updated