Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

How to Create IPathFinder

Community Beginner ,
Jul 04, 2023 Jul 04, 2023
Hello InDesign SDK Developers.
I keep testing and I can't solve the problem, so I'm looking forward to your help.

I want to perform XOR operation on two or more closed paths using IPathFinder.

UIDRef uidRef1 = CreatePath()...;//CreatePath function receives PathPointList as a parameter and creates a closed path.UIDRef uidRef2 = CreatePath()...; InterfacePtr<IPathGeometry> pathGeometry(uidRef2 , UseDefaultIID()); InterfacePtr<IPathFinder>iPathFinder(uidRef1 , UseDefault()); if (! iPathFinder) { break; } iPathFinder->AddPath(pathGeometry); IPathGeometry *result = nil; iPathFinder->combine(result, IPathFinder::kXOr); I can't get iPathFinder here, I need help on how to do it thank you

 

TOPICS
Bug , How to , SDK
427
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 04, 2023 Jul 04, 2023

Untested:

IPathFinder is on kUtilsBoss.

Utils<IPathFinder>()->combine(…)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 06, 2023 Jul 06, 2023

 

Thanks Dirk Becker.
With your help, I solved my iPathFinder problem.
However, the problem has not been resolved yet.
The result differs depending on the result value in the combine function. 
If the result is treated as nil, the combine operation is forcibly terminated. How can I know what to do with the initial value of the result when AddPath is performed on two or more path objects and combine is called?

UIDRef uidRef1 = CreatePath(...);
UIDRef uidRef2 = CreatePath(...);
UIDRef uidRef3 = CreatePath(...);

InterfacePtr<IPathGeometry> pathGeometry1(uidRef1 , UseDefaultIID());
InterfacePtr<IPathGeometry> pathGeometry2(uidRef2 , UseDefaultIID());
InterfacePtr<IPathGeometry> pathGeometry3(uidRef3 , UseDefaultIID());

Utils<IPathFinder>()->AddPath( pathGeometry1 );
Utils<IPathFinder>()->AddPath( pathGeometry2 );
Utils<IPathFinder>()->AddPath( pathGeometry3 );

 

IPathGeometry *result = pathGeometry1;
status = Utils<IPathFinder>()->Combine( result, IPathFinder::kXOr )

When I run this part, there is no error, but it does not work normally. 
How should I set the value of IPathGeometry *result?

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 06, 2023 Jul 06, 2023

I never used IPathFinder. Anyway, let's have a look.

When called from the UI, the call is wrapped into a bunch of nested commands. So the pathfinder itself does not create appropriate commands, it is just the raw functionality taking place within.

If you never heard about commands, the long related section in the programming guide is worth a read.

 

The question is do you want the changes in the document - use the command. Or do you need some temporary buffer? Use a non-persistent boss for that happens to implement IPathGeomentry. kPathGeometryBoss looks like made for that.

 

Otherwise, say hi to kMergePathCmdBoss.

After some filtering (locked? bah!) the UIDList holds e.g. 2 kSplineItemBoss. The IPathGeometry of the command appears to be empty and the IntData is 1 in my case. Numeric value of kUnion, while on later try kDifference is 2.

Besides to the call to IPathFinder, there are sub-commands:

- do something about object attribute overrides

- delete the other page item(s)

- of course, removing it/them from the hierarchy on the way

- Tons of notifications - Preflight wants to reconsider, the items get removed from the selection, maybe there is some associated XML to clean up.

As result, the kMergePathCmdBoss has a filled-in IPathGeometry, and a reduced UIDList (only the last item survived). Likely it also copies the IPathGeometry into the survivor.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 07, 2023 Jul 07, 2023
LATEST
Hello Dirk Becker.
Thank you very much.
I feel very lucky to have your help this time.
 
I solved the problem by using kMergePathCmdBoss instead of IPathFinder.
I tried to solve the problem using IPathFinder, so I couldn't sleep for several days, 
but I succeeded in an hour using kMergePathCmdBoss. 
ByungwanJung_0-1688732518969.png

 

InterfacePtr<ICommand> mergePathCmd(CmdUtils::CreateCommand(kMergePathCmdBoss)); 
mergePathCmd->SetItemList ( itemList );
 
InterfacePtr<IIntData> intData(mergePathCmd, UseDefaultIID());
intData->Set(combineType); // Use the appropriate operation type
 
status = CmdUtils::ProcessCommand(mergePathCmd);
 
Thank you again.
Jung Byungwan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines