XP Programming

2»

Comments

  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    edited April 2022

    Yea, I should have mentioned that in the tutorial. No reason to have people guess includes. I'll see to updating it.

  • BidmaronBidmaron Traveler

    Monsen, if you get tired tell me to stop, but to continue with Part 2, the following includes are necessary for the Note example:

    #include <string>

    #include <vector>

    #include <cstdlib>

  • BidmaronBidmaron Traveler

    OK. First roadblock on doing the tutorial code.

    Problem: on running XP2ColorCircle, none of the pentagram circles change color.

    Below is a screen shot after running the macro using 72 as the color and even after screen redraw:

    I have checked that the layer Standard, upon which they are drawn, is unlocked.

    To troubleshoot, I did some breakpoints in the Process code and verified that all 4 pentagram circles are entering the 'if circle' conditional block, and I saw that the colors were getting incremented.

    It appears that the changes being made aren't getting committed into the drawing database somehow. I didn't see any kind of function call in the _DLMGR.h file, so I don't know what's going on.

    This is my project file:

    So here is my main.cpp file since it doesn't seem like I can share the whole solution because it's too big:


  • MonsenMonsen Administrator 🖼️ 81 images Cartographer

    Seems this is a bit of shortsightedness on my behalf.

    Entities in CC3+ have 2 colors, the outline and the interior color. My code only changes one of those. Try changing your line width to 0.1 and fill style to solid, then draw a few more pentagrams, and then use the color change command, and you will see that it works just fine.

    The real culprit is here:

       if (c.CStuff.LWidth == 0.0f) {
          c.CStuff.EFStyle = 0;
       }
    

    Basically, if the line width is Zero, let's switch to a hollow fill style, so we don't get a filled polygon. But this also leads to the entity being displayed in that second color. And my color-changing code doesn't change that one.

    You can change this by changing the color changing code to something like the below, or you can change the above code to set the line width to 0.1 or something instead of switching fill style.

       if (circle) {
          circle->CStuff.EColor2 = (color %= 255)++;
          circle->CStuff.EColor = (color %= 255)++;
          EDraw(pEntRec);
       }
    
  • BidmaronBidmaron Traveler

    Thanks, Monsen. At work so will have to check this evening, but makes total sense. I hope I'm not pestering you too much, sir.

  • MonsenMonsen Administrator 🖼️ 81 images Cartographer

    Not at all. Don't be afraid to ask questions.

  • BidmaronBidmaron Traveler

    The XPSheetList routine of the second tutorial has an error.

    This is the line with the error. It is intended to copy the sheet name from the Sheet entity to the variable to be placed into the dialog box.

    strcpy_s(sheetName,sheet->SName);
    

    This line should be:

    strcpy_s(sheet->SName,sheetName);
    

    I know this is a problem because the screen shot below of the dialog for the sheet tool shows that the code as it exists has blanked out the names of the sheets upon which the symbols were placed.



  • MonsenMonsen Administrator 🖼️ 81 images Cartographer
    edited April 2022

    No, that's not right. strcpy_s takes the destination as the first parameter, the source as the second parameter:

    My downloadable example code also have the line in the first form, and it does not blank out the sheet name when run. If I do reverse it and use the form you suggest, then I get the exact problem you describe.

    There has to be something else to it.

  • BidmaronBidmaron Traveler

    OK, let me start over with a new file. Maybe I corrupted it during testing somehow. Sorry for the false alarm.

  • BidmaronBidmaron Traveler

    @Monsen You were right of course. I started over, and I must have scrambled my map somehow. It works fine the way you said with strcpy_s

  • MonsenMonsen Administrator 🖼️ 81 images Cartographer

    Yea, messing up your map is kind of easy when you are given direct access to the raw data. Part of the fun :)

    JimP
Sign In or Register to comment.