AutoCAD | Learning C # and Autocad .NET API
kandi X-RAY | AutoCAD Summary
kandi X-RAY | AutoCAD Summary
Learning C# and Autocad .NET API hello this is my journey learning C# and AutoCAD API. Connect with me on LinkedIN.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AutoCAD
AutoCAD Key Features
AutoCAD Examples and Code Snippets
Community Discussions
Trending Discussions on AutoCAD
QUESTION
I'm creating my own application to programmatically add a block from an external file into the model space. My custom command begins by asking the user to specify the filepath of the block to be inserted.
The problem is that the filepath has spaces in it, therefore AutoCAD command line accepts each space as pressing enter. Is there any way to suppress this issue for entering the filepath?
I'm hoping someone can help me out with the below code.
Thanks in advance.
...ANSWER
Answered 2022-Mar-13 at 07:18You can use a PromptStringOptions with Allowspaces = true. Apart from that, you should check the PromptResult.Satus value before going on.
QUESTION
I have a method that mimics the BURST command but using the .NET interface with AutoCAD. Select a block, type the command, works no problem. But what I'm trying to do is make it into a callable method so that I can get a collection of ObjectIds, all BlockReferences, and have it BURST them one at a time.
I have the BURST method working, and can prove that the correct ObjectIds are making it to the method call each time. It loops through each entity in the collected blocks after the .Explode command, but for some reason the work never gets published (re: nothing ends up exploded).
I'm stuck, been working on this for hours now and it's clearly beyond my understanding. I'm guessing it's one tiny thing I overlooked but can't see it.
...ANSWER
Answered 2022-Feb-17 at 19:01Nothing is exploded because the parent transaction was not committed.
So every child transaction is rolled back.
One way to avoid starting a new child transaction for each ObjectId is to pass the parent transaction as an argument.
Then commit the parent transaction in the top level method, after bursting.
Here's a quick and dirty example:
QUESTION
I am trying to silently send a synchronous Lisp command to autocad from c# code.
Here's how we send a Synchronous command to autocad.
...ANSWER
Answered 2022-Feb-09 at 22:26The title of my question was misleading. I didn't need to run lisp code silently, I needed to run commands in acad's command line silently. It just happened to be that acad's command line accepts lisp code so that's what I was using.
Instead of running lisp code, I used the method ActiveDocument.Editor.Command()
to send my command to autocad. This method is synchronous and is affected by the system variable cmdecho
.
I encountered a subsequent problem; because I was calling this method from a button in the banner with RelayCommand
, Editor.Command
was throwing the exception eInvalidInput
because I was in the Application context instead of the Document context.
The best way to handle this was to split my first method in two and call the second method with ActiveDocument.SendStringToExecute()
which uses the command line so I end up in the Document context. But because SendstringToExecute()
is async, I had to rework my method's logic a bit.
Here is the final result (simplified)
QUESTION
I am trying to put together a script to fix PDFs a large number of PDFs that have been exported from Autocad via their DWG2PDF print driver.
When using this driver all SHX fonts are rendered as shape data instead of text data, they do however have a comment inserted into the PDF at the expected location with the expected text.
So far in my script I have got it to run through the PDF and insert hidden text on top of each section, with the text squashed to the size of the comment, this gets me 90% of the way and gives me a document that is searchable.
Unfortunately the sizing of the comment regions is relatively course (integer based) which makes it difficult to accurately determine the orientation of short text, and results in uneven sized boxes around text.
What I would like to be able to do is parse through the shape data in the PDF, collect anything within the bounds of the comment, and then determine a smaller and more accurate bounding box. However all the information I can find is by people trying to parse through text data, and I haven't been able to find anything at all in terms of shape data.
The below image is an example of the raw text in the PDF, the second image shows the comment bounding box in blue, with the red text being what I am setting to hidden to make the document searchable, and copy/paste able. I can get things a little better by shrinking the box by a fixed margin, but with small text items the low resolution of the comment box coordinate data messes things up.
To get this far I am using a combination of PyPDF2 and reportlab, but am open to moving to different libraries.
...ANSWER
Answered 2022-Feb-03 at 07:44I didn't end up finding a solution with PyPDF2, I was able to find an easy way to iterate over shape data in pdfminer.six, but then couldn't find a nice way in pdfminer to extract annotation data.
As such I am using one library to get the annotations, one to look at the shape data, and last of all a third library to add the hidden text on the new pdf. It runs pretty slowly as sheet complexity increases but is giving me good enough results, see image below where the rough green borders as found in the annotations are shrunk to the blue borders surrounding the text. Of course I don't draw the boundaries, and use invisible text for the actual program output, giving pretty good selectable/searchable text.
If anyone is interested in looping over the shape data in PDFs the below snippet should get you started.
QUESTION
I am trying to find out how I can get AutoCAD to recognize a running instance. However I am running into an issue where the AcadApplication
is not recognized does not exist on Application as outlined in the code below.
I am making this to avoid having to make a direct plugin, but rather a WPF application that can communicate with AutoCAD separately (creating a toolkit that can also provide function unrelated to AutoCAD in the future). If this approach is a bad idea feel free to also let me know since I am looking for the best approach to this problem.
Would anyone be able to assist me into getting this code to work for AutoCAD 2022? Currently this is running in a WPF Application running .NET Framework 4.7.2 (References are manually included from my installation of AutoCAD)
...ANSWER
Answered 2022-Feb-02 at 21:57Here's a sample class that you can use to get started.
My guess, is there are two root causes as to why you can't launch an AutoCAD instance:
- you are not using a Autodesk.AutoCAD.Interop.AcadApplication reference
- you are using the wrong progId for AutoCAD 2022
Give this code a try and then see if you can work it backward to find the issue.
When you want to launch AutoCAD / use AutoCAD without a direct plugin, you need to use the COM interop objects and not Autodesk.AutoCAD.ApplicationServices.
Also, here are the paths to the new references you will need:
C:\Program Files\Autodesk\AutoCAD 2022\Autodesk.AutoCAD.Interop.dll
C:\Program Files\Autodesk\AutoCAD 2022\Autodesk.AutoCAD.Interop.Common.dll
C:\Program Files (x86)\Reference\Assemblies\Microsoft\Framework.NETFramework\v4.7.2\Microsoft.VisualBasic.dll
QUESTION
BOUNTY EDIT
Not looking for an answer - already posted and accepted one. Just trying to raise awareness with this bounty.
Original post
I have come across a nasty VBA bug that makes Property Get
procedure calls really slow. This is most likely due to a recent Office update (I have Office365). It only affects Excel on 32 bits.
The bug
Consider a class called Class1
with only the code:
ANSWER
Answered 2022-Jan-05 at 23:10I tested your example in 2013-32 with an empty class v with the 100 properties, and only got a small difference in timings. I can only assume something related with your particular setup.
However I'd say your 0.45 sec is slow even in an old system, and the reason for that is your particular use of a large Collection. Two ways to improve -
Counter intuitively with large collections it's much faster to use Keys rather than Indexes to retrieve items, populating is only slightly slower with keys. Referencing col.Item(1) is fast but bigger indexes are progressively slower, seems internally the collection is looped to find the given index each time ...
QUESTION
I found the amazing question How can I use clojure as scripting language for a Java program? which helped tremendously, but I can't figure out how to get an existing Java instance into Clojure. The use case is something really similar to AutoCad's AutoLisp. I want to let users manipulate an application with scripting so that they are free to do more without my help or input. I want to have a class that does some work
...ANSWER
Answered 2022-Jan-24 at 19:45import clojure.java.api.Clojure;
import clojure.lang.Var;
import clojure.lang.RT;
import clojure.lang.Compiler;
public class Main {
public static void main(String[] _argv) {
// Using String instead of Testing just to avoid having to
// deal with multiple files during compilation.
String s = "Hello there";
// Needed to allow creating new namespaces.
// If you ever get stuck with some functionality not working, check out
// Compiler.load - there are other bindings in there which, I guess, might be important.
// So you can either copy all the bindings here or simply use Compiler.load instead of
// Compiler.eval for script pieces that don't require bindRoot.
Var.pushThreadBindings(RT.mapUniqueKeys(RT.CURRENT_NS, RT.CURRENT_NS.deref()));
try {
Compiler.eval(Clojure.read("(ns user)"));
// def returns the var itself.
((Var) Compiler.eval(Clojure.read("(def s)"))).bindRoot(s);
Compiler.eval(Clojure.read("(println s \"in\" (ns-name *ns*)))"));
} finally {
Var.popThreadBindings();
}
}
}
QUESTION
I have line and circle model (I know the equation that is formed by using data). I would like to find tangent points or equation of yellow circle (radius is determined by me) which tangent with my line and circle.
At the beginning I tried to solve mutual equation separately line and yellow circle and circle and yellow circle reduce to 3 equation to 2 equation but I couldn't find a solution maybe calculation error.
Is there any more clear way or opinion to find these points by python?
For example:
Circle-1: (x-8,98)^2 + (y-42,53)^2 = 6,4^2
Line-1: y=22,904x-115,9707
Tangent Circle:(x-a)^2 + (y-b)^2 = 14^2
Tangent points (Founded in AutoCAD):
X1=6,2028 Y1=26,0978
X2=12,4953 Y2=37,1832
...ANSWER
Answered 2022-Jan-24 at 17:15Your problem has multiple solutions.
You have 6 unknowns, so the simplest way to solve the problem (not necessarily the fastest) is to craft 6 equations using the constraints defined. After that, you can use a symbolic Math engine like Sympy to solve the system of equations.
Let's start by defining the equations.
- We know that the line-2 between P1 and the center of the second circle (its center is hereafter noted as (x_a2, ya_2)) is perpendicular to the line 1 whose slope is equal to a . So the slope of the perpendicular line-2 is equal to -1/a. And since A2 and P1 are on line-2, we have the following
- P1 is on circle-2, so
- P1 is on line-1, so
- We know that the Euclidean distance between the center of the two circles is equal to r1 + r2, so
- P2 is on circle-1,
- P2 is on circle-2,
We have finally the 6 equations, so we can use Sympy to solve the system of equations.
I recommend running the following code on a Jupyter notebook
QUESTION
I am trying to make a program that utilises a textbox that has text options listed in it that can be clicked on.
As a textbox example:
[Selection:<1><2><3>]
so the user could then as example click on (over the text) <2>
to select the 2nd option or <3>
so select the 3rd option. The idea comes from the AutoCAD
commands prompt which uses a similar system.
How would I achieve something like this in vb.net code (if its even possible)?
...ANSWER
Answered 2022-Jan-14 at 20:48Try this:
QUESTION
I have generated a dxf file but when I opened it with AutoCAD, crashes AutoCAD and gives a message ID 11 incorrect: already used. the dxf content: https://github.com/tarikjabiri/dxf/blob/dev/examples/latest.dxf I can't spot the problem 3 days I am trying to solve it. I think something wrong with the APPID because it holding the ID 11 or the Handle in the language of DXF.
I have a dxf working: https://github.com/tarikjabiri/dxf/blob/dev/examples/Minimal_DXF_AC1021.dxf
Thanks in advance.
...ANSWER
Answered 2022-Jan-06 at 18:13There are two minor issues:
DIMSTYLE
table
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install AutoCAD
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page