AutoCAD - Is it possible to analyze .dwg file? - autocad

I want to analyze dwg file. Is it possible?
I'm trying to write a some program that could analyze the content of the .dwg file. for example the program could say if a door in a building model could be opened.
I've found this article that explains how to read autoCAD file. also i've seen some program that can open and view .dwg files, but nothing to analyze the content.
I want to know if there is something similar to that, that analyze the content of the .dwg file, and to know if there are SDK that can help me analyze?

You could, but it's not easy.
An AutoCAD .DWG file is basically just geometry (lines and arcs). You may have some well organized files with block, let's say a "Door" block, but it's not 100% confident: for instance, you may have "Door1" and "Out Patio Door" as a block name.
For both cases, the way the main problem is to understand the geometry and interpret somehow. Assuming you can, then you have some options of paths:
Run an in-process plugin on AutoCAD: this can be accomplished in C++, .NET (C#, VB.NET), LISP or VBA. There are tons of resources, like DevCenter, blog and blog.
Use as a library to access the objects, like RealDWG or other open source. This might be tricky and requires programming (like above).
Use a webservice, like AutoCAD I/O, to upload a .DWG and a .DLL (.NET) code that will analyse your drawing.
To interpret the geometry (with any of the above), the BRep API is the best way to analyze the geometry, like intersection points and other relations. The the blog you'll find some samples around it, but I don't believe there is something on this area. Check this and this.
Finally, as a summary, with .NET you'll need the Autodesk.AutoCAD.DatabaseServices namespace with Line, Arc, BlockReference and the respective IntersectWith methods to do some basic analysis.
Now if you have an AutoCAD Architecture .DWG drawing, it might be easier as some basic objects are available as part of the APIs, like Walls and Doors. I don't believe that's the case, but if so, check at this link.

RealDWG costs unreal money. But you can use Teigha. Its cost is less, but its capabilities are great. Also you can read DWG Specification.

The existing SDKs mentioned will allow you to examine the AutoCAD entities and data in a dwg file.
Recognizing AutoCAD entities (lines, arcs, blocks etc.) as something of interest to you (door, window, cabinet etc.) would require that you identify these entities as such. You could do that with attributes or hidden data embedded in the AutoCAD entities.
Attributes are built-in functionality in AutoCAD. Hidden embedded data would require custom programming.

You can use the open source LibreDWG library to run a number of AutoCAD native commands such as DATAEXTRACTION that are able to parse the file and extract the contents.
Mixpeek is one free option that does just this:
pip install mixpeek
from mixpeek import Mixpeek
mix = Mixpeek(
api_key="my-api-key"
)
mix.index("design_spec.dwg")
This /index endpoint will extract the contents of your DWG file, then you can search for terms for analysis.
mix.search("retainer", include_context=True)
[
{
"file_id": "6377c98b3c4f239f17663d79",
"filename": "design_spec.dwg",
"context": [
{
"texts": [
{
"type": "text",
"value": "DV-34-"
},
{
"type": "hit",
"value": "RETAINER"
},
{
"type": "text",
"value": "."
}
]
}
],
"importance": "100%",
"static_file_url": "s3://design_spec_1.dwg"
}
]
More documentation here: https://docs.mixpeek.com/ and a writeup: https://medium.com/#mixpeek/search-the-contents-of-dwg-files-with-python-1fd2fc0772af

Related

hwpf, xwpf, hssf, and xslf poi picture extraction

I'm looking to extract all images from new and legacy Word documents and spreadsheets to assist in a real time document classification system, and looking at the documentation, I seem to have run into a problem. I'm having no problems finding documentation within the hwpf module and packages for extracting images from the file, but when it comes to the other 3, it seems as though they don't support the same methods.
What I want to do is to have one block of code that is document type agnostic when it comes to the 4 above mentioned types, I just want fast, easy access to the pictures in the files so I can move on to my next task, but at this point it looks like only the hwpf module supports extraction of pictures or the methods in 'PicturesTable'.
I'm also somewhat concerned about the performance of the library: it looks like it loads the entire file when all I want to do is scrape the images out of it. Any suggestions on a library that operates directly on the 'Data' bytestream and the folder structure of the .***x zip files?
I've already tried using OLEtools to try to extract pictures from the streams, and I'm now moving on to this tool. I havn't tried any tools that operate on the lower levels of the documents yet though.

Create Multiple Slides from a List with Common Template

I have created a certificate design with powerpoint.
Now I have to create 100+ copies of it... each with a different name (the recipent).
I was wondering if there was an easy way to do it...
I can have the list of names in excel or txt.
I am open to other ideas as well, like changing the slide into an images and batch processing it in a simple way
You may also try out SlideMight, a tool for merging hierarchical data with PowerPoint templates. SlideMight supports iteration over data, to generate slides or to populate tables. There is more functionality, but you don't seem to need that. SlideMight is in fact a coding system, like mail merge for Word is.
Input data format is at this time just JSON; you would need to convert your Excel sheets first, e.g. using this Excel to JSON add-in for Excel.
There are versions for Windows and Mac OS X.
More information is at www.SlideMight.com
Disclaimer:
I am the owner of Delftware Technology, the company that developed SlideMight.
And I am one of the developers.
This is a question that really belongs in SuperUser, not StackOverflow (which is intended for coding questions, not software how-to-use questions).
But ...
Save your names to a plain notepad TXT file, one name per line.
Start PowerPoint, choose File, Open and point to your TXT file (you may force the matter by choosing . in Files of type:
Apply whatever template you like to the result.
I have a commercial add-in that'll do this and quite a bit more, but from your description, you don't need it.

Single or multiple translation.json files for i18n?

I'm working a project in Aurelia and using the aurelia-i18n plugin. So far it looks great and translation is working and instantly updating interface language when I change locale.
Question: is there a logical, organizational or performance advantage to using multiple translation files vs. a single translation file? For instance:
Should I just put everything into one file?
my-aurelia/locales/en/translation.json
my-aurelia/locales/es/translation.json
Or should I separate into multiple translation files?
my-aurelia/locales/en/nav.json
my-aurelia/locales/en/words.json
my-aurelia/locales/en/phrases.json
my-aurelia/locales/es/nav.json
my-aurelia/locales/es/words.json
my-aurelia/locales/es/phrases.json
Here's how I have instantiated the plugin for this example (inside the export function configure(aurelia) { of my-aurelia/src/main.js, but I'm at an important design crossroads.
aurelia.use.plugin('aurelia-i18n', (instance) => {
// register backend plugin
instance.i18next.use(XHR);
// adapt options to your needs (see http://i18next.com/docs/options/)
instance.setup({
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json',
},
lng : 'es',
ns: ['words','phrases','nav'],
defaultNS: 'words',
attributes : ['t','i18n'],
fallbackLng : 'en',
debug : false
});
});
One json language file or multiple json language files? Any additional advice?
Performance-wise, a single file per language will be slightly faster on the initial load because fewer requests are necessary. However, this micro-optimization will be negligible, and you should put more value towards code structure and readability, especially for other people working on the code after you.
Will a single file become so large, that it will be hard for people to find the right entry, and change the content of the JSON file? If not, and you do not expect it to grow to such a size, you're probably best off using a single file.
Will people wonder if you put "Gracias/Thank You" in words (thanks) or phrases (thank you)? I recommend using a structure which is clear for someone who is not familiar with your code.
Lastly, one of the organization structures I have not seen you mention, but which I have used myself, is to order i18n files based on your views. This makes it easy to find the file which needs to be changed, as you already know which view you're working so you don't have to look for the i18n.

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

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.
As you can see from web-sites such as this one, there's no "one format to rule them all." Every CAD program (like every other computer program ...) wound up defining "its own, app-specific format." AutoCAD is just one of many. But there are also various "standard" (sic ...) formats ... almost-inevitably "XML-based" ... which were specifically designed to allow model-information to be shared among programs. Typically, you "export" the model to one of these formats.
"And then, you Google to find where somebody else(!) has already perfected a Python module that knows how to read that file-format." You can be quite sure that you will not have to write-and-debug that code yourself. (After all, "you are not the first soul to have needed to do this sort of thing ...")
Normally, you don't try to deal with "the application's native format," because, even if the vendor in question actually saw fit to publish it, it contains "everything, including the kitchen sink." Stuff that you don't need. An "export file" is usually preferable for (and, was designed for ...) this very reason.
you may consider use Autodesk 3d webgl viewer technology, see a running sample for end-users at https://360.autodesk.com/viewer and check the full API (REST & JavaScript) at https://developer.autodesk.com/

How to create this sublime text syntax?

I am trying to create a simple sublime syntax where when the first word of a line is "DONE" the whole line turns to a different color.
For example:
- do this
DONE - do that // this line turns green
- but also do this
My two questions are:
- How does one go about creating a ST syntax
- How would I create the above simple syntax.
The most you could highlight is the region containing text. I don't know if that's what you are looking for. To do this would require defining a tmLanguage file and modifying you tmTheme file. The tmLanguage file describes a set of regular expressions for which a scope is applied to the text within ST. The tmTheme file takes the scopes applied, and applies some coloring. I'm not an expert on writing either of these files, so you may need to do some experimentation on your own.
For information on writing syntax files, see here and here. The theme files are much simpler, in terms of defining them. Those guides recommend using AAAPackageDev, which is not necessary (and not compatible with ST3 last I checked). The language files are all XML, which you can work with, but I find working in JSON or YAML easier. If you feel the same way, you can start with the below snippet and use SerializedDataConverter to convert between XML and PLIST/JSON.
{
"name": "Syntax Name",
"scopeName": "source.syntax_name",
"fileTypes": [""],
"patterns": [
],
"uuid": "ca03e751-04ef-4330-9a6b-9b99aae1c418"
}
I can't recall the location of any references, but I'm sure they're out there. Though, simply viewing some existing theme files may be enough for you. TO view these, you can use PackageResourceViewer. Isn't really necessary if you are working in ST2, but makes things much easier in ST3. To begin working on your own custom theme, I'd copy the contents of the theme file you are currently to a new file, and save it in your Packages/User directory. That way, you always have something to revert to, in case you mess something up.

Resources