Derek,
The new drawing logic seems to be working well.
By the way, I came up with a fairly straightforward way for FCB to create a .KT3 file which can be loaded into KnotTyer3D.
For this to work, your SPart tile should only be used to indicate the SPart of a rope. When the user places one or more SPart tiles on the diagram, store the locations (e.g. "fan"). Let's assume that there is one SPart tile on the diagram, and it's the north-pointing tile.
To create the coordinates for KnotTyer3D, simply assign a multiple of 10 to each row and column in the FCB diagram (a=10, b=20, c=30, etc.).
Now, if the SPart tile has a value of "fan" in FCB (i.e. the north-pointing SPart tile is at location "fa"), then the first .KT3 coordinates are: 60, 10, 0 (the third value will always be 0 unless a section of rope is traveling *behind* another section of rope).
Since the SPart tile is pointing north, the next tile in sequence will be at "fb" (i.e. just below the SPart tile). You'll need to keep track of which direction the rope is traveling at each step. If the "fb" tile is a vertical strand of rope, for example, then the next tile in sequence is at "fc" (the same is true if the "fb" tile is one of the crossing tiles). If the "fc" tile curves to the west then the direction has changed, so the next tile is at "ec", and so on. Using this approach, you can programmatically follow the rope through all of its gyrations, building a sequence of coordinates in the proper order. The order in which the user placed the FCB tiles makes no difference, because at each step you simply need to scan through FCB's list of coordinates (for each color) looking for the appropriate location (e.g. "ec") in order to find out which tile is at that location.
With the exception of the curved tiles, the .KT3 coordinates are very simple. The first two values will always be the numeric equivalents for the column and row (e.g. "60, 20" if the tile is at "fb"). The third value in the .KT3 coordinates will always be 0 unless the tile is a crossing tile and the rope is traveling in a direction which will take it *behind* a section of rope, in which case the third value needs to be -1.
For a curved tile, we need to create three .KT3 coordinates based on the direction in which the rope is traveling. In the following instructions, "c" refers to the numeric column value of the curved tile (e.g. f=60) and "r" refers to the numeric row value. "Upper right" refers to the curved tile in the FCB pallet which is in the upper right corner of the four curved tiles.
-- For the "upper right" curved tile:
If the rope is traveling north, then the .KT3 coordinates are:
c, r+4, 0
c-2, r+2, 0
c-4, r, 0
If the rope is traveling east, then the .KT3 coordinates are:
c-4, r, 0
c-2, r+2, 0
c, r+4, 0
-- For the "upper left" curved tile:
If the rope is traveling east, then the .KT3 coordinates are:
c+4, r, 0
c+2, r+2, 0
c, r+4, 0
If the rope is traveling north, then the .KT3 coordinates are:
c, r+4, 0
c+2, r+2, 0
c+4, r, 0
-- For the "lower left" curved tile:
If the rope is traveling south, then the .KT3 coordinates are:
c, r-4, 0
c+2, r-2, 0
c+4, r, 0
If the rope is traveling west, then the .KT3 coordinates are:
c+4, r, 0
c+2, r-2, 0
c, r-4, 0
-- For the "lower right" curved tile:
If the rope is traveling east, then the .KT3 coordinates are:
c-4, r, 0
c-2, r-2, 0
c, r-4, 0
If the rope is traveling south, then the .KT3 coordinates are:
c, r-4, 0
c-2, r-2, 0
c-4, r, 0
When there are no more FCB tiles to process then you're done. If you come to a WEnd tile then write the coordinates for that tile (e.g. "70, 80, 0" if the WEnd tile is at "gh").
That's all there is to it! Simply provide a button which prompts the user for a filename, then write the KnotTyer3D coordinates to the file using a .KT3 extension, then the file can be loaded into KnotTyer3D (for a single rope, it usually looks best if you use the "Rainbow" option in KnotTyer3D).
If the user placed a second SPart tile then write "C" to the output file to indicate a new rope ("C" stands for "Color"). Then follow the above logic to write the coordinates for the second rope. This will cause both ropes to be drawn simultaneously in KnotTyer3D. Use "CF" instead of "C" if you want the first rope to be drawn before the second rope. Use "CJ" (or "CFJ") if you want the first rope to be a closed loop such as a sling ("J" stands for "Join").
For a spar, first write out the KnotTyer3D coordinates of the spar just as if it were a rope. Then use "CF" and write out the KnotTyer3D coordinates for the rope.
I have attached the .CYP file for a Bowline, and a .KT3 file which I made using the above logic (you'll need to rename it from FCB_Bowline.txt to FCB_Bowline.kt3 in order to load it into KnotTyer3D).
Anyway, this will get you started (if you're interested), and the logic can be tweaked later (such as smoothing out the curves).
Dave