New Development Article

MonsenMonsen Administrator 🖼️ 46 images Cartographer
I've just posted my second article in my XP development series.

I know this is a bit too technical for some of you, but I still hope it is useful.

You can check out the series.

Comments

  • LoopysueLoopysue ProFantasy 🖼️ 39 images Cartographer
    It probably is for me, but I think it's wonderful that you are catering for all our many and varied interests :)
  • Aside from a purely style issue (I'd embed the "code explanations" in the source as //comments// myself so the reader wouldn't have to flip back and forth) this blog was very useful for understanding entities and how they work. Of particular interest to me was how easily the third and fifth examples could be adapted to import/export map notes from/to text files. If the next blog could cover file input and output operations for XPs that would be great. Also is there a more efficient way of locating particular entities than "walking the drawing list" and testing the contents of each? (This would include any SELBY1 picking from the XP.)
  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited June 2019
    For reading/writing text files, I would just rely on standard C++ ways of handling files, no special handling required just because this is an XP. I'll probably not be handling that in the blog, since I want to focus on what is particular for XP's, and not end up being a generic C++ tutorial.

    If you are looking for a particular entity, you'll have to walk the drawing list (as long as you can stick to testing for type, like I do in the examples, the operation is reasonably cheap), but when you are dealing with selections, you can always just use the DLS_Sel flag in DLScan to have it returned selected entities only.
  • DaltonSpenceDaltonSpence Mapmaker
    edited June 2019
    Posted By: MonsenFor reading/writing text files, I would just rely on standard C++ ways of handling files, no special handling required just because this is an XP. I'll probably not be handling that in the blog, since I want to focus on what is particular for XP's, and not end up being a generic C++ tutorial.

    I was hoping to use the CC3+ file dialogs for opening and closing the notes files, but if not how do I get the current drawing name/path so I can import/export drawing notes from/to a text file with the same name in the same directory with the extension ".notes"? (Fortunately I found some good C++ tutorials online since I'm a bit rusty in that language.)

    Posted By: MonsenIf you are looking for a particular entity, you'll have to walk the drawing list (as long as you can stick to testing for type, like I do in the examples, the operation is reasonably cheap), but when you are dealing with selections, you can always just use the DLS_Sel flag in DLScan to have it returned selected entities only.

    I'm not exactly clear on how to do this. How do I set up the RDATA entry to select single or multiple entities to process?

  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited June 2019
    CC3+ mostly relies on the standard Windows dialogs for file picking operations. Here is a small example using the open dialog, and the Microsoft Documentation



    I'll talk about RDATA more in a later installment of the series, but basically, to use a selection, set up RDATA like this:

    1
    2
    3
    4
    5
    6
    FORMST(lpszPrompt, "Pick Entities:\0")
    pENTREC ent;

    RDATA SelectReq =
    { sizeof(RDATA), RD_Pick1, NULL, RDF_C, (DWORD*)& ent,
    (DWORD*)& lpszPrompt,RDC_PICK, PickEntity2, NULL, NULL, 0, NULL, 0 };


    For the data type, you can either use RD_Pick for a regular selection, or RD_Pick1 which selects just one entity. Note that RD_Pick obeys the current select method, so it may or may not prompt the user to make a selection, depending on that setting.

    Now, if you used RD_Pick, you need to walk the drawing list, using the DLS_Std|DLS_Sel flags. This will only return entities that was part of the selection. If you used RD_Pick1, the selected entity is never really selected, but you get a reference to the entity record returned to the ent variable instead, no need to access the drawing list.
  • Thanks, this will be useful. I would still like to know how to get the current drawing path/filename (as per the GETDWGNAME macro command) so I can at least open the file dialog the current drawing's path. Or if there is a simpler way to get the CC3+ data directory path than opening and reading the "@.ini" file in the installation directory.
  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited June 2019
    These should be the functions you need:

     1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    // File name of current drawing
    char * filename = GetCurDwgFileName();

    // File name including full path of current drawing
    char * fullfilepath = GetCurDwgFullName();

    // CC3+ data directory
    char datadir[MAX_PATH];
    FullFileName("@",datadir);

    // CC3+ Installation directory
    char installdir[MAX_PATH];
    FullFileName("#",installdir);

    // Path of the current drawing (not including file name)
    char drawingdir[MAX_PATH];
    FullFileName("$",drawingdir);
Sign In or Register to comment.