Kean Walmsley

July 2009

Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Twitter Updates

    follow me on Twitter



    « Using a palette from .NET to display properties of multiple AutoCAD objects | Main | Coming in September: Autodesk DevCamps - Customization and Application Development Conferences »

    July 18, 2007

    TrackBack

    TrackBack URL for this entry:
    http://www.typepad.com/services/trackback/6a00d83452464869e200e008da8ba58834

    Listed below are links to weblogs that reference Accessing DWG files not open in the AutoCAD editor using .NET:

    Comments

    Thank you Kean for the theme,
    One of the frequent problems is to check all (or some) dwg files in a folder. It is necessary to detect a valid dwg version, to check for some specific entities (present or absent), to add some objects (e.g. format box) and to publish (or to plot).

    Hi Nikolay,

    Thanks - this is great input.

    I'll try to cover the batch-processing aspect (going through files in a folder, checking their versions, and then reading/performing some operation), but printing/plotting can only happen on editor-resident drawings.

    AutoCAD currently needs the graphics pipeline to generate printed graphics, and this is not present for side databases. So this is certainly something interesting to cover, but would be more about batching inside the editor than using side databases.

    Regards,

    Kean

    Hi Kean!

    Excellent example! From an academic stand-point, what would really make this appliction "shine" is replacing the command line prompt with a Windows Form.

    Regards,

    Nick

    Hi Kean

    Great topic. I would be interested in opening drawing database and change attribute text in a blockrefrence. Save and close in the end.


    Cheers
    Tore

    Kean,
    If plotting is impossible in an invisible mode then let us save modified dwg file to a subfolder "Ready for plotting".

    Good example.But I want to know if I can access the entities in a drawing without start the AutoCAD.Maybe this is a DBX topic,but I know nothing about DBX,where I can find some helpful articles like here?You know I take here as my ObjectARX classroom:),Do you know some other blogs talk about ObjectDBX ?Thank you.

    Travor -

    I'm not sure if you're aware, but RealDWG is the new name for ObjectDBX (and I did mention RealDWG in the above article, albeit briefly).

    The above code will work with very little modification in RealDWG, and I'll add it to my list to do a specific article on RealDWG at some point.

    Regards,

    Kean

    Hi Kean.
    Thank you for your mention.It seems I should get something about RealDWG.I am looking forward to your RealDWG articles.Many thanks.

    Hi Kean,

    I've really enjoyed reading your articles. This is the best resource I have found for AutoCAD .NET programming. Thank you.

    I am working (or about to start) on creating a program that goes through the dwg files in a directory and purges each drawing. Don't ask why one would want to do this as it is not for me :), but it what I'm interested in and it kind of ties in with the first poster's desire to iterate through a list of drawings.

    Thanks again.

    Just read your latest post. It seems you have already done this. While here though, is it possible to do what I asked using the PurgeAll() command? (I haven't experimented yet, and I'm being lazy). Thanks again.

    Hi Kyle,

    You could fire off the -PURGE ALL command (sending the command to the commandline - this would mean the drawing had to be loaded in the AutoCAD editor, mind) or you could create a list of all the objects (blocks, layers, linetypes, etc.) and pass that list through to db.Purge(). This would remove any objects that should not be purged. The remaining object IDs in the list can be used to open and erase the purgable objects in the drawing.

    I'll add this to my list to tackle, at some point.

    Regards,

    Kean

    That's great information Kean. I am interested in how it can be accomplished through the C++ code/Arx. What about doing this with system variables such as dimtxt, dimscale etc?

    Here is my problem scenario. I have a block in drawing A1.dwg, and now I want to insert A1.dwg block into another drawing A2.dwg. I am trying to get the dimtxt value for A1.dwg before the insertion process so that I can perhaps set the current drawings dimtxt attribute to the one from A1.dwg. I know it's quite simple for current drawings, but what about other drawings remotely.

    So to sum it up, the function should be able to read dimtxt system variable from a drawing that is not open and return the dimtxt value for that drawing.

    Vector

    I think the possible solution to this problem would be to use ObjectDBX. However, as per my information there is no way to access system variables from another drawing that is not open in an AutoCAD session through ObjectDBX. Not even GetVariable and SetVariable, since GetVariable and SetVariable are methods of AcadDocument,
    they only work on AcadDocuments (they're just wrappers for the ObjectARX counterpart of the (getvar) and (setvar) LISP
    functions). So there's no method for getting/setting system variables stored in drawings that are accessed directly via
    ObjectDBX.


    Could you please confirm on this?

    Thanks,
    vector

    Vector -

    As long as you have a pointer to the Database (or AcDbDatabase) then you can access the "Dimtxt" property - db.Dimtxt (or use the AcDbDatabase::dimtxt() function).

    This is true whether inside AutoCAD or using RealDWG (the new name for ObjectDBX).

    Regards,

    Kean

    Kean:

    Do you know what signature would work? I can't find the Object Model documentation anywhere :

    Suppose I do this

    AcDbDatabase pDb( Adesk::kFalse );
    pDb.dimtxt(dimtxtVal, DwgName);

    is this the right signature?

    Where DwgName is the drawing name whose dimtxt I want

    Thanks,
    Vector

    Vector -

    You need to use readDwgFile() to read your DWG into the AcDbDatabase before accessing the dimTxt() method using:

    double dt = db.dimtxt();

    You'll find the documentation on the ObjectARX SDK under the docs folder.

    It seems as though you're new to using ObjectARX. Are you sure you want to stick with C++, rather than using .NET? (Even without substantial documentation I find AutoCAD .NET coding easier and the object model much more discoverable).

    A word of caution... I'd recommend against developing anything in ObjectARX (C++) unless you've worked through the Labs (in the "arxlabs" folder) or attended introductory training provided by my team. It will really save you a lot of thrashing.

    Regards,

    Kean

    Kean,

    How to access the ACADMap ObjectData Tables, without opening the dwg in ACAD Editor.

    Senthil

    Sorry, Senthil - I don't know the Map 3D APIs and am unlikely to address this topic on this blog.

    You should submit your question via one of the discussion groups or the ADN website (if you're a member).

    Kean

    hi kean
    this is satheesh from india.i'm currently assined wth an autocad automation project where i hv to draw in autocad from .net environment.i'm using managed dlls with c# as my programming language .
    i'm currently stuck in a sitaution where i hv to do fillet command to join two lines.for ur knowledge i 'm just a beginner who hv just started learning about autocad.net programming.u might feel this is a simple doubt,but it wud be a great help for me.
    thanx

    Satheesh -

    Please post your question to the AutoCAD .NET Discussion Group, or submit it via ADN, if you're a member.

    Regards,

    Kean

    hi
    please,
    Im after openning file dwg closed autocad .
    im guide please
    bye

    Sorry - I don't understand, but it doesn't seem related to the code in this post. Please submit your question to one of the discussion groups.

    Kean

    I get a eBadDwgHeader exception when trying to open dxf files. Is it possible to open dxf files with db.ReadDwgFile() or is there another way to open/import them using RealDWG?

    You can use RealDwgFile(). It's probably a problem with the DXF file, or with the Database constructor.

    Make sure you don't use the default constructor (Database db = new Database();).

    For R13-R2009 DWG files use:

    Database db = new Database(false, ...);

    For earlier DWGs use:

    Database db = new Database(true, ...);

    Kean

    I have tried different Database constructors but DXF files still give eBadDwgHeader exceptions, even with your EOF example. DWG files works fine.

    I'm using RealDWG 2009 and have added
    acdbmgd.dll and acmgd.dll to the projects references. All my dxf files can be opened correctly in autocad.

    Regards,

    Mattias

    Verify your Comment

    Previewing your Comment

    This is only a preview. Your comment has not yet been posted.

    Working...
    Your comment could not be posted. Error type:
    Your comment has been posted. Post another comment

    The letters and numbers you entered did not match the image. Please try again.

    As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

    Having trouble reading this image? View an alternate.

    Working...

    Post a comment

    Feed & Share

    Search