MIT License

项目介绍

chuongmep/CadPythonShell 是一个托管在 GitHub 上的开源项目,主要使用 C# 编写,采用 MIT License 许可证,目前获得 122 个 Star、26 次 Fork。

仓库全名
chuongmep/CadPythonShell
开源许可证
MIT License
Star 数
122
Fork 数
26
未关闭 Issue
3

README 摘要

CADPythonShell alt="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…

完整内容见 GitHub 原始 README 或本页 。

常见问题

CadPythonShell 用什么语言开发?

主要使用 C# 编写,采用 MIT License 许可证,目前有 122 个 Star。

CadPythonShell 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 CadPythonShell 的源码?

可以直接克隆仓库:git clone https://github.com/chuongmep/CadPythonShell.git,默认分支为 dev;安装与运行步骤见仓库 README。

CadPythonShell 最近还在维护吗?

仓库最近一次更新为 2025年4月6日,当前有 3 个未关闭 Issue;Star 数为 122,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

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

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
184
价值分
81
活跃状态
活跃

语言占比

Batchfile
C#
CSS
HTML
JavaScript
PowerShell
Python
XSLT

Release

贡献者

README

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.

评论

暂无评论