Solution for covert below python program to lisp program in autocad

Solution for covert below python program to lisp program in autocad

kadamsudarshan57
Participant Participant
1,226 Views
6 Replies
Message 1 of 7

Solution for covert below python program to lisp program in autocad

kadamsudarshan57
Participant
Participant

(import 'matplotlib.pyplot as plt)
(import 'numpy as np)

(def elevation_points (list (list 0 100) (list 5 150) (list 10 100) (list 15 120) (list 20 80)))
(def section_points (list (list 0 50) (list 5 75) (list 10 50) (list 15 60) (list 20 40)))

(plt.figure (figsize (list 10 5)))
(plt.plot (apply 'zip (apply 'list elevation_points)) :marker "o" :linestyle "-" :color "b")
(plt.title "Elevation Profile")
(plt.xlabel "Distance (m)")
(plt.ylabel "Elevation (m)")
(plt.savefig "elevation_plot.png")
(plt.show)

(plt.figure (figsize (list 10 5)))
(plt.plot (apply 'zip (apply 'list section_points)) :marker "o" :linestyle "-" :color "r")
(plt.title "Section Profile")
(plt.xlabel "Distance (m)")
(plt.ylabel "Elevation (m)")
(plt.savefig "section_plot.png")
(plt.show))

0 Likes
Accepted solutions (2)
1,227 Views
6 Replies
Replies (6)
Message 2 of 7

daniel_cadext
Advisor
Advisor
Accepted solution

Matplotlib isn’t in lisp autolisp, why not use pyautocad?

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes
Message 3 of 7

kadamsudarshan57
Participant
Participant

Thank-you sir but py autocad  means 

0 Likes
Message 4 of 7

kadamsudarshan57
Participant
Participant
Sir please automatic building section command creat by auto lisp program all type of 2d plan
0 Likes
Message 5 of 7

kadamsudarshan57
Participant
Participant

Please make  command 2d building section on 2d floor get point,put all heights for all type building plan  on 2d floor plan by autolisp program or command

0 Likes
Message 6 of 7

hosneyalaa
Advisor
Advisor
Accepted solution

if possible to drop here sample dwg file

0 Likes
Message 7 of 7

daniel_cadext
Advisor
Advisor

Pyautocad is here:

You can interact with AutoCAD using ActiveX, kind of like VBA, but using python

https://pypi.org/project/pyautocad/

https://github.com/reclosedev/pyautocad

 

For the more advanced and adventurous :

https://github.com/CEXT-Dan/PyRx

 

You can use PyRx and wxPython to show matplotlib plots, a small example

 

 

#imports
from numpy import arange, sin, pi

import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure

import PyRx as Rx
import PyGe as Ge
import PyGi as Gi
import PyDb as Db
import PyAp as Ap
import PyEd as Ed
import wx
#imports

#define a command 
def PyRxCmd_wxpy():
    try: 
        res = Ap.ResourceOverride()
        dlg = TestDialog(None, -1, "Plot",wx.Size(500,300))
        if dlg.ShowModal() == wx.ID_OK:
            print("Yay!")
    except Exception as err:
        print(err)

        
class CanvasPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = Figure(figsize=(1,1))
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

    def draw(self):
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * t)
        self.axes.plot(t, s)
   
class TestDialog(wx.Dialog):
    def __init__(
            self, parent, id, title, size, pos=wx.DefaultPosition,
            style=wx.DEFAULT_DIALOG_STYLE, name='dialog'
            ):

        wx.Dialog.__init__(self)
        self.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        self.Create(parent, id, title, pos, size, style, name)
        Ap.Application.applyHostIcon(self.GetHandle())
        self.pltpanel = CanvasPanel(self)
        self.pltpanel.draw()

 

plotlib.png

 

 

Python for AutoCAD, Python wrappers for ARX https://github.com/CEXT-Dan/PyRx
0 Likes