I don't have code to do this, but can give an an outline of what I believe is required, This is untested and might be incomplete:
- At the start of your Figure paragraph, insert a marker by calling Doc.NewAnchoredMarker()
- Get the default properties used to create the new marker by calling Marker.GetProps()
- Change the returned MarkerTypeId property to the "XRef" marker type:
use Doc.GetNamedMarkerType() to fetch the marker type id - Change the returned MarkerText property to a unique string,
- Change other returned properties as required
- Update the properties of the new marker by calling Marker.SetProps()
- At the location for your cross reference, insert an XRef by calling Doc.NewAnchoredFormattedXRef()
- Get the default properties used to create the new cross reference by calling XRef.GetProps()
- Change the returnedXRefFile property to the file containing the marker
- Change the returnedXRefSrcText property to the unique string in the marker
- Change the returnedXRefFormat poroperty as required:
use Doc.GetNamedXRefFmt() to fetch the format id - Change other returned properties as required
- Update the properties of the new cross reference by calling XRef.SetProps()
- Update the cross reference cy calling Doc.UpdateXRef.
I'm sorry, but I don't have the bendwidth rght now to give further help.