GithubHelp home page GithubHelp logo

chuongmep / cadpythonshell Goto Github PK

View Code? Open in Web Editor NEW
64.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.

cadpythonshell's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cadpythonshell's Issues

Civil3D not load ribbon CadPythonShell

Search existing issues

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the problem I am experiencing.

The problem

Civil3D not load ribbon CadPythonShell when install and open first time

Release version

2023

Operating system

Windows 10

Steps to reproduce the behavior

1.Install CadPythonShell
2. Open
3. See problem

Log files

No response

Screenshots

No response

Additional context

No response

Fatal Error : Unhandier e0434352h Exception at 2F50CD29h

Search existing issues

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the problem I am experiencing.

The problem

  • Problem cause when use new version with ironpython 3.4

Release version

1.0.9

Operating system

Windows 10

Steps to reproduce the behavior

  1. Click to open python shell

Log files

No response

Screenshots

acad_fJbGSYmvYg

Additional context

No response

Doubled items in `snoop database`

Search existing issues

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the problem I am experiencing.

The problem

Hello! Very nice and useful tool!

Just want to report that all the items are doubled as you can see at the bottom in the screenshot section.
Every element I've inspected has that doubled data, I've also checked and they are the same.

Release version

1.0.7

Operating system

Windows 11

Steps to reproduce the behavior

  1. Open a drawing
  2. Snoop Database
  3. Inspect elements

Log files

No response

Screenshots

immagine
immagine

Additional context

No response

__vars__ in documentation

Search for existing feature requests

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the feature I am requesting.

The feature request

Please provide some pointers in the documentation and/or the config variables page about how variables can be used in code.

Proposed solution

print(__vars__['var_name'])

Additional context

No response

Cannot import ifcopenshell

Search existing issues

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the problem I am experiencing.

The problem

I tried to import the following module but it doesn't work.
http://ifcopenshell.org/python
I used the win 32 bit 2.7 version.

Release version

1.0.5

Operating system

Windows 10

Steps to reproduce the behavior

No response

Log files

No response

Screenshots

No response

Additional context

No response

Show the file name & path where the "Save This Script Into File" button will save a script

Search for existing feature requests

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the feature I am requesting.

The feature request

Problem: When you click the "Save This Script Into File" button, it's ambiguous what file will be saved. Presumably it's whatever file you last opened. But if you haven't opened a file yet, or you have but then click the "Save This Script Into New File" button, the "Save This Script Into File" button presumably has a different behavior.

Proposed solution

When you mouse-over the button, it displays "Save This Script Into File." Perhaps it could also display at least the file name of what file it will actually save into once you click it. Like, "Save This Script Into File - script1.py" for example. I think this would remove the ambiguity of what the button is actually going to do, which would make me worry less that I'm about to overwrite one of my scripts on accident when I click it.

Additional context

Example:
image

If this functionality is already present and I've just missed it, please let me know.

Thanks!

External Script doesnt add a button in the ribbon

Search existing issues

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the problem I am experiencing.

The problem

When uploading an external script, it doesnt create a button in the ribbon, even if i restart autocad. In the revit version it does, so other people can reuse my scripts just by click in it.

Release version

1.1.3

Operating system

Windows 11

Steps to reproduce the behavior

  1. Go to Python Shell Menu.
  2. Click in configures CPS.
  3. In External Scripts Add a .py script.
  4. Give a Name and Ok.
  5. It does nothing.

Log files

No response

Screenshots

No response

Additional context

No response

Problem when open cadpythonshell

Search existing issues

  • I have searched the issue tracker and confirmed that I was unable to find existing issues for the problem I am experiencing.

The problem

Cad Snoop not load.

Release version

1.0.5

Operating system

Windows 10

Steps to reproduce the behavior

Open PythonShell from ribbon

Log files

No response

Screenshots

acad_XAhMxMnTIV

Additional context

No response

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.