• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

How can get child items of a PageUID?

Enthusiast ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

How can get child items of a PageUID?

This is my code, but childCount getting =0:

 

			// Get the list of spreads in this document
			InterfacePtr<ISpreadList> spreadList(document, UseDefaultIID());

			// Iterate over all the spreads
			int32 spreadCount = spreadList->GetSpreadCount();
			for (int32 spreadIndex = 0; spreadIndex < spreadCount; spreadIndex++)
			{
				
				UIDRef spreadUIDRef(database, spreadList->GetNthSpreadUID(spreadIndex));
				InterfacePtr<ISpread> spread(spreadUIDRef, UseDefaultIID());
				ASSERT(spread);
				if (!spread) {
					break;
				}
				// Iterate over all the pages on the spread.
				int32 numberOfPages = spread->GetNumPages();
				for (int32 nPage = 0; nPage < numberOfPages; nPage++)
				{

					UID pageUID = spread->GetNthPageUID(nPage);
					UIDRef pageUIDRef = UIDRef(database, pageUID);
					InterfacePtr <IHierarchy> pageHierarchy(pageUIDRef, UseDefaultIID());
					
					//Get chid items:
					int32 childCount = pageHierarchy->GetChildCount();
					for (int32 childIndex = 0; childIndex < childCount; childIndex++)
					{
						InterfacePtr<IHierarchy> child(pageHierarchy->QueryChild(childIndex));
						UIDRef childUIDRef = ::GetUIDRef(child);
					}

				} // iterate pages in spread


			} // iterate spreads
TOPICS
SDK

Views

278

Translate

Translate

Report

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

correct answers 1 Correct answer

Engaged , Jun 01, 2021 Jun 01, 2021

Here we would use

// Get child Items
DataBase* db = document.GetDataBase();
UIDList pageItems(db);
spread->GetItemsOnPage(pageIndexInSpread, &pageItems, kFalse);
for (int32 iitem = 0; iitem < pageItems.Length(); iitem++)
{
   UIDRef itemRef(pageItems.GetRef(iitem));
   // process each item here
}

Very best regards,

Olivier

 

Votes

Translate

Translate
Engaged ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

Here we would use

// Get child Items
DataBase* db = document.GetDataBase();
UIDList pageItems(db);
spread->GetItemsOnPage(pageIndexInSpread, &pageItems, kFalse);
for (int32 iitem = 0; iitem < pageItems.Length(); iitem++)
{
   UIDRef itemRef(pageItems.GetRef(iitem));
   // process each item here
}

Very best regards,

Olivier

 

Votes

Translate

Translate

Report

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
Enthusiast ,
Jun 01, 2021 Jun 01, 2021

Copy link to clipboard

Copied

Yes, Thank you,

I know this way.

But Can we can get from pageUIDRef?

InterfacePtr <IHierarchy> pageHierarchy(pageUIDRef, UseDefaultIID());

I can get child from SpreadUIDRef. But pageUIDRef can't.

Votes

Translate

Translate

Report

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 Expert ,
Jun 02, 2021 Jun 02, 2021

Copy link to clipboard

Copied

LATEST

Hi @daitranthanhoa,

Page does not own the items that are present on it, they are owned by the spread. So I don't think that the IHierarchy of the page will have pageItems as its descendants(which is what you get as result), it should only lead to the spread boss if you move up the hierarchy. So I suppose the method provided by @Olivier Beltrami is the correct way to get the pageitems on a page.

-Manan

Votes

Translate

Translate

Report

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