Giter VIP home page Giter VIP logo

chuongmep / cadpythonshell Goto Github PK

View Code? Open in Web Editor NEW
63.0 7.0 19.0 23.41 MB

An IronPython console for Autocad and Civil 3d API, include full snoop Database to explore API

Home Page: https://chuongmep.com/posts/2022-04-05-Cad-Python-Shell.html

License: MIT License

C# 95.80% Python 2.29% Batchfile 0.01% PowerShell 0.24% HTML 0.46% CSS 0.04% JavaScript 0.40% XSLT 0.76%
cad civil3d autodesk autocad plugin addin dynamo autocadlookup civil3dlookup snoop

cadpythonshell's Introduction

CADPythonShell

Autocad API Platform License: MIT

ReSharper Rider Visual Studio 2022 .NET Framework

Publish Github All Releases HitCount follow on Twitter

Introduction

This is obviously a fork of RevitPythonShell, bringing an IronPython interpreter to Autodesk Autocad, and it would not be possible without the great work of everyone involved with the RPS project. It's still pretty rough around the edges and provides only basic functionality at this time. I'm sharing my work so far, in the hopes that together we can expand it further.

The CADPythonShell (CPS) ,lets you to write plugins for Autocad in Python, provides you with an interactive shell that lets you see the results of your code as you type it. This is great for exploring the Autocad API.

The biggest limitation is that you can't deploy DLLs with custom scripts at this time and you can't subscribe to events at startup time.

IronPython 3

IronPython 3.4 uses Python 3.4 syntax and standard libraries and so your Python code will need to be updated accordingly. There are numerous tools and guides available on the web to help porting from Python 2 to 3.

IronPython 3 targets Python 3, including the re-organized standard library, Unicode strings, and all of the other new features.with user upgrade from IronPython 2 to IronPython 3, please follow Upgrade from IronPython 2 to IronPython 3.

Various differences between IronPython and CPython can follow at Differences IronPython and CPython.

Features

  • Interactive IronPython interpreter for exploring the API
    • With syntax highlighting and autocompletion (in the console only)
    • Based on the IronLab project
  • Batteries included! (Python standard library is bundled as a resource in the CADRuntime.dll)
  • Full access to the .NET framework and the Autocad and Civil3D API
  • Configurable "environment" variables that can be used in your scripts
  • Save "external scripts" for reuse and start collecting your awesome hacks!
  • Run scripts at Autocad or Civil startup
  • Full Snoop info object Autocad or Civil3D (Database,Editor,Entity,etc,..)
  • Interactive Snoop from console with IronPython

Installation

  • Download last install stable(msi) from Release
  • Use command PythonConsole to open Console or use command PythonShellSetting to open form setting
  • See guide install detail at How-to-Install-CadPythonShell

Note : Support for 5 last version(2019-2023) Autocad or Civil 3D. Older versions can be used but will not guarantee the expected performance.

Basic Usage CadPythonShell

  • PythonConsole - Open Python Console

  • PythonShellSetting - Open Setting Config Console

Use Snoop In Python Shell In Python Script :

  • Snoop - Quick Snoop Object Sample In CAD or Civil3D
  • sn.Snoop(obj) - Snoop Object by Python Console In CAD or Civil3D
  • snoop(obj) - Snoop Object by Python Console or Execute python code In CAD or Civil3D

Write Console Sample In Console :

ed = doc.Editor
ed.WriteMessage("Hello")

Create Script Execute ShowAlertDialog Demo :

import clr
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
doc = Application.DocumentManager.MdiActiveDocument
ed = doc.Editor
db = doc.Database
# Write Code Below
Application.ShowAlertDialog("Hello World!")

Create Script Execute ShowAlertDialog Demo :

Note : you can see more example in folder Script Examples

Basic Usage Snoop

  • SnoopDB - Snoop Database In CAD or Civil3D

  • SnoopEd - Snoop Editor In CAD or Civil3D

  • SnoopEnts - Snoop Entities In CAD or Civil3D

  • SnoopNEnts - Snoop Entities Nested In CAD or Civil3D

  • SnoopByHandle - Snoop By Handle In CAD or Civil3D

  • SnoopEvents - Snoop Follow Events In CAD or Civil3D

Contribute

  • Don't hesitate to file any issues you stumble uppon. (Tho I don't guarantee I'll be able to solve them all for you)

Getting started:

Learn some python:

Learn about the Autocad API:

License

This project is licensed under the terms of the MIT License.

Sponsors

Thanks for providing a free All product IDE for this project.

Credits

  • Daren Thomas (original RPS Developer) RPS
  • Joe Moorhouse (interactive shell was taken from his project IronLab
  • Dimitar Venkov (original port to Navisworks)
  • ChuongMep (original port to Autocad)
  • The rest of the RPS contributors
  • Nice 3 Point for process CI/CD
  • Icon 8 Free Wiki icons in various UI design styles for web, mobile
  • htlcnn origin of project AutocadLookup
  • Autodesk Developer Network project MgdDbg support full snoop database in Autocad.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.