CADsite

  • vr 27 01 2023, 08:27:11
  • Welkom, gast
Log in of registreer jezelf.

Login met gebruikersnaam, wachtwoord en sessielengte
Geavanceerd zoeken  

Nieuws:

Pagina's: [1]   Omlaag

Auteur Topic: AI genereren van Code (of iets anders)  (gelezen 317 keer)

EddyBeerke

  • forumverslaafde
  • ******
  • Offline Offline
  • Berichten: 2434
  • 1d CADSITE.be niet bezoeken = 1 dag niet geleefd!
    • Bekijk profiel
    • Mijn site
AI genereren van Code (of iets anders)
« Gepost op: vr 09 12 2022, 10:01:41 »

Dit is de link:
https://chat.openai.com/chat

Wat kan het:
De site kan van alles beantwoorden maar ook code schrijven.
Hier een voorbeeld:

Mijn vraag:
please write a vlisp code to draw a line in autocad

AI antwoord:
(defun c:line ( / p1 p2)
   (setq p1 (getpoint "Specify first point: "))
   (setq p2 (getpoint p1 "Specify second point: "))
   (command "line" p1 p2)
   (princ)
)
Citaat
This code defines a function called c:line that prompts the user to specify the starting and ending points of the line. It then uses the line command to draw the line between these two points.

To use this code in AutoCAD, you can type it in the command line and press Enter to run it. This will define the c:line function and make it available for use in your AutoCAD drawing. To draw a line, simply type line in the command line and press Enter. This will run the c:line function and prompt you to specify the starting and ending points of the line. Once you have specified these points, the line will be drawn in your AutoCAD drawing.

Keep in mind that this code is just an example and can be modified and expanded upon to suit your specific needs and preferences. For more information and examples of VLISP code, you can check out the AutoCAD documentation or search online for VLISP tutorials and examples.

Nog een voorbeeld:
please write a vba code to draw a line in autocad

AI antwoord:
Sub DrawLine()
   Dim p1 As Variant
   Dim p2 As Variant

   ' Prompt the user to specify the starting and ending points of the line
   p1 = ThisDrawing.Utility.GetPoint("Specify first point: ")
   p2 = ThisDrawing.Utility.GetPoint("Specify second point: ", p1)

   ' Draw the line between the specified points
   ThisDrawing.ModelSpace.AddLine p1, p2
End Sub
Citaat
This code defines a subroutine called DrawLine that prompts the user to specify the starting and ending points of the line. It then uses the AddLine method to draw the line between these two points in the current drawing.

To use this code in AutoCAD, you can open the VBA editor and paste the code into a new module. This will define the DrawLine subroutine and make it available for use in your AutoCAD drawing. To draw a line, simply run the DrawLine subroutine in the VBA editor. This will prompt you to specify the starting and ending points of the line. Once you have specified these points, the line will be drawn in your AutoCAD drawing.

Keep in mind that this code is just an example and can be modified and expanded upon to suit your specific needs and preferences. For more information and examples of VBA code, you can check out the AutoCAD documentation or search online for VBA tutorials and examples.

Nog een:
please write a C# code to draw a line in autocad

AI:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;

namespace DrawLine
{
    public class Line
    {
        [CommandMethod("DrawLine")]
        public void DrawLine()
        {
            // Get the current document and database
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            // Start a transaction
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                // Open the Block table for read
                BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

                // Open the Block table record Model space for write
                BlockTableRecord btr = trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                // Create a new line
                Line line = new Line(new Point3d(0, 0, 0), new Point3d(10, 10, 0));

                // Add the line to the block table record
                btr.AppendEntity(line);

                // Save the new object to the database
                trans.AddNewlyCreatedDBObject(line, true);

                // Save the changes and dispose of the transaction
                trans.Commit();
            }
        }
    }
}
Citaat
This code defines a class called Line that contains a method called DrawLine. The DrawLine method creates a new Line object using the Point3d constructor and adds it to the current drawing.

To use this code in AutoCAD, you can compile it into a .NET assembly and load it into AutoCAD using the NETLOAD command. This will define the DrawLine command and make it available for use in your AutoCAD drawing. To draw a line, simply type DrawLine in the command line and press Enter. This will run the DrawLine command and draw a line in your AutoCAD drawing.

Keep in mind that this code is just an example and can be modified and expanded upon to suit your specific needs and preferences. For more information and examples of C# code, you can check out the AutoCAD documentation or search online for C# tutorials and examples.
Gelogd

julien

  • Administrator
  • forumverslaafde
  • ******
  • Offline Offline
  • Berichten: 3026
    • Bekijk profiel
Re: AI genereren van Code (of iets anders)
« Reactie #1 Gepost op: vr 09 12 2022, 14:18:51 »

Dit is echt wel heel indrukwekkend!  :shock:
Gelogd

roy_043

  • forumverslaafde
  • ******
  • Offline Offline
  • Berichten: 1478
  • BricsCAD 18
    • Bekijk profiel
Re: AI genereren van Code (of iets anders)
« Reactie #2 Gepost op: za 10 12 2022, 11:09:01 »

Probeer eens een complexere taak...
Gelogd
Pagina's: [1]   Omhoog