FAQ Database Discussion Community


Using C# to Join AutoCAD Entities into a Block Programmatically

c#,autocad,autocad-plugin
I'm trying to write a method that prompts the user to select all the entities they want to combine into a block and then joins them together into a block and returns the block reference. Right now it looks like this. /// <summary> /// Returns all entities in an AutoCAD...

Block insert via Matrix3d can have attributes?

c#,autocad
Good Day, I'm trying to create a csharp program to insert multiple blocks onto an Autocad drawing, each one with a different insert point. For simplicity given the block is another drawing I'm using a matrix insert that I'll paste below. The problem is that the block I'm bringing in...

AutoCAD C# Select objects after SendStringtoExecute

c#,autocad,autocad-plugin
Does anyone know how to select objects after SendStringtoExecute? The best for me is select object using fence or a point. Here's the part of my code: foreach (ObjectId objId in NormalblkTblRec) { if (objId.ObjectClass.Name == "AcDbArc") { Entity en1 = (Entity)trans.GetObject(objId, OpenMode.ForWrite); Arc arcs = (Arc)(Object)en1; Point3d[] arcpoints =...

“exception: access violation writing” error in Python (ctypes)

python,activex,autocad,comtypes
I've been learning python (2.7) for a couple of weeks to be able to automatise autocad, so, be patient I'm python noob. I'm trying to get the attributes of a newely created block to modify them, the doc says that in VBA it would be: Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "TESTBLOCK",...

Entities wrong when importing multiple DXF files

c#,.net,autocad,autocad-plugin
I have 3 different BlockTableRecord's that I want to update. I am loading external .dxf files that contain the entities for each block definition. Now when I delete the old entities and load in the new ones it works perfectly fine but as soon as I start updating the second...

Set default value for string prompt

c#,.net,autocad,autocad-plugin
The editor class has a method called GetString which prompts the user for a string value via AutoCAD's command prompt. I call it in this wrapper method: public static string PromptUserForString(string message = "Enter a string: ", string defaultAnswer = "") { return _editor.GetString("\n" + message).StringResult; } The argument message...

Autocad scaling

autocad,cad,autodesk
I'm studing AutoCAD and encountered with a scale problem. I write a simple detail, but when i'm setting Lineweight 1.00 mm AutoCAD draw 2cm line instead of 1mm line. I tried to change scale in Annotate -> Dimensions -> Scale factor = 0.05, but it didn't help. Here is two...

Access autocad object properties without opening it by VBA

vba,autocad
I have been using folder browser for VBA, I could paste the code of it, but bottom line is that I get returned file name as a string. Is there any way to access drawing properties (i.e number of layouts) without open? Public Sub TestFileDialog() dwgname = FileBrowseOpen("C:", "*", ".dwg",...

AutoCAD: Access group pivot in C#

c#,autocad,autocad-plugin
I am writing a plugin for AutoCAD in C#. I would like to change the position of the pivot point of a group. It is possible to do that by mouse clicking but after deselecting and reselecting the group, it automatically moves back to it's default position (which looks like...

What to do with a corrupted DWG file?

autocad,dwg,libredwg
I work in AutoCAD 2002. The main file of the drawing when opening AutoCAD gives out "It wasn't succeeded to open this drawing. It contains the incorrect or damaged data". Tried to apply the command to "restore" did not help. Writes that found 3 errors and that all recovered. And...

How does CAD save 3d shapes? and can I read from it?

autocad,cad
For example, how does CAD save such a 3d shape? I mean, does it save it like something: points = [[0,0,0],[0,1,0],[1,1,0],[1,0,0]] lines = [[points[1], points[2]],[points[2],points[3]]] Because I want to draw some 3d shapes(in python and render it in webpages), and I want to know how they are stored in files....

How do I check if Point3d is not null?

c#,null,nullable,autocad,autocad-plugin
My approach was... Autodesk.AutoCAD.Geometry.Point3d point = null; but I can't seem to set a Point3d to null. Can anyone tell me why and how I would check whether a Point3d is null? (By Point3D I mean Autodesk.AutoCAD.Geometry.Point3d)...