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

Questions about Selections

Community Beginner ,
Jan 25, 2012 Jan 25, 2012

Hi all,

I have some unsolved questions about selections, I have panel, ASB, CSB, layoutSelectionBoss and so on:

  1. How is my selection called? What steps I need to do for that?
  2. How to get data from selection? There shlould be defined abstract methods in ASB, and its real implementation in CSB or eg. LayoutSelectionBoss?

Thank you in advice

TOPICS
SDK
6.6K
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

correct answers 1 Correct answer

Community Expert , Jan 29, 2012 Jan 29, 2012

In order to create your own selection suites you need to follow the following steps.

1. Create an interface for the selection suite and place it as an AddIn in the IntegratorSuite and the suite boss that you need to extend. Like for layout you could use the kLayoutSuiteBoss.

2. The implementation for the interface added in the IntegratorSuite will be the ASB implementation, the code for this is pretty much templated, refer SDK sample code to have an idea about it.

3. The implementation for the inte

...
Translate
Community Expert ,
Jan 29, 2012 Jan 29, 2012

In order to create your own selection suites you need to follow the following steps.

1. Create an interface for the selection suite and place it as an AddIn in the IntegratorSuite and the suite boss that you need to extend. Like for layout you could use the kLayoutSuiteBoss.

2. The implementation for the interface added in the IntegratorSuite will be the ASB implementation, the code for this is pretty much templated, refer SDK sample code to have an idea about it.

3. The implementation for the interface added in the other suite boss will be the CSB implementation. Inside this class you can write the code specfic to your needs.

Regading the call on this code and how do you get your code executed, first you will have to get the selection manager interface which is generally obtained from the activeselection but there are other ways too refer the SDK for it. From this selectionmanager interface query the interface of your suite and if your suite is available you can call it's method else you will get a nill pointer.

I think this should make it pretty much clear, for more clarifications refer the SDK samples and the programming guide.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

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 ,
Feb 13, 2012 Feb 13, 2012

Thank you for that explanation, it was wery useful

I have one more question:

In my LayoutCSB I would like to get SeletionHeight, for this, there is GetSeletionHeight in IGeometrySuite. Am I right?

So this method should look like that:

int STSuiteLayoutCSB::SelectionHeight()

{

  InterfacePtr<IGeometrySuite> mySuite(this, UseDefaultIID());

  return mySuite->GetSelectionHeight();

}

this will result in problem...

In IGeometrySuite are these two methods:

virtual void GetSelectionHeight( Transform::CoordinateSpace boundsSpace, Geometry::BoundsKind boundsKind, Transform::CoordinateSpace measurementSpace, K2Vector<PMReal>& results) const = 0;    

virtual void GetSelectionHeight( Geometry::BoundsKind boundsKind, Transform::CoordinateSpace measurementSpace, K2Vector<PMReal>& results) const = 0;

Iam a bit confused, how to use these methods, could you please help me here?

thank you in advice

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
Guide ,
Feb 13, 2012 Feb 13, 2012

This might help.

          InterfacePtr<IGeometry> geometry(itemToModify, UseDefaultIID());

          ASSERT(geometry);

          if (!geometry) {

  return;

          }

          PMMatrix inner2parent = ::InnerToParentMatrix(geometry);

          PMRect boundsInParentCoords = geometry->GetStrokeBoundingBox(inner2parent);

 

P.

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 ,
Feb 13, 2012 Feb 13, 2012

Could you explain this code a little bit, please?

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
Guide ,
Feb 13, 2012 Feb 13, 2012

Look in TransformUtils.h, the InnerToParentMatrix worked for my application but you might want InnerToPasteboardMatrix. Once you have got your PMRect in the right coordinates you can use the Height from the PMRect.

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 Expert ,
Feb 13, 2012 Feb 13, 2012

What exactly do you want, from what i see from Pickory's code is you are trying to get the height of the bounding box of the current selection in the layout. For ex if you have three image boxes selected you need the height of the bounding box that encloses all these image boxes. Kindly clarify so that we can provide better pointers for the solution.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

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 ,
Feb 13, 2012 Feb 13, 2012

I want get height, width and position of selected frame on page. I know that every time would be selected only one frame.

Right now I have done step one(according to your answer) and now Iam fighting with step two, i found some samples in sdk, so Iam trying to understand what kinds of methods I would need to write in ASB and how would they be implemented in CSB.

I thing method in ASB for height of selected item would look like this:

void STSuite::GetSelectionHeight(Geometry::BoundsKind boundsKind,  Transform::CoordinateSpace mesurementSpace, K2Vector<PMReal> &result)

{

     CallEach(make_functor(&IGeometrySuite::GetSelectionHeight, boundsKind, mesurementSpace, result), this);

}

After that I need to write its implementation in CSB. That would be consisted of these steps: get IGeometry InterfacePtr and call method GetSelectionHeight. Am I right?

thanks

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 ,
Feb 14, 2012 Feb 14, 2012

So I have mooved on,

Right now I have my method in ISTSuite, in ASB and now I would like to create that method in CSB. Could you help me little bit with its implementation, please? I would like to get height of selected item. I know that this can be obtained from IGeometrySuite, so I will create InterfacePtr on IGeometrySuite and next?

Thank you in advice,

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 ,
Feb 14, 2012 Feb 14, 2012

Finaly, I have code for obtaining width and height working perfectly!! Thanks again

I have 2 last questions:

1. If I would like to get x coordinate of left top corner of selection, which interface pointer I should get (on which suite?)?

2. almost same question, but I would like to get page on which is selected content.

Thanks again

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 Expert ,
Feb 14, 2012 Feb 14, 2012

if you wrote the code in accordance to what Pickory had hinted then the PMRect itself has the the top() method that will give you the X coordinate of the top left corner

And for the 2nd question you will can use the method  "GetOwnerPageUID" in the "ILayoutUtils", but this method will return the UID of the spread if the pageitem does not lie on a page so make a check for that too.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

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 ,
Feb 14, 2012 Feb 14, 2012

I was not able to use Pickory's code, because it gave me error.

void STSuiteCSB::GetSelectionPositionX(K2Vector<PMReal> &result)

{

  InterfacePtr<IGeometry> iGeometrySuite(this, UseDefaultIID());

          if (iGeometrySuite == nil) {

  ASSERT_FAIL("Error");

          }

          PMMatrix inner2parent = InnerToParentMatrix(iGeometrySuite);

          PMRect boundsInParentCoords = iGeometrySuite->GetStrokeBoundingBox(inner2parent);

 

}

I know that InnerToParentMatrix is a method from TransformUtils.h, but when I use #include "TransformUtils.h" I get following error:

Undefined symbols:

  "typeinfo for ISTSuite", referenced from:

      typeinfo for CPMUnknown<ISTSuite>in STSuiteASB.o

ld: symbol(s) not found

collect2: ld returned 1 exit status

When I dont include header for utils, i cant call InnerToParent...

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 Expert ,
Feb 15, 2012 Feb 15, 2012

i think you need to write ::InnerToParentMatrix instead of InnerToParentMatrix.

Manan Joshi

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 ,
Feb 15, 2012 Feb 15, 2012

I have been trying all possible combinations and still got errors...

Regarding point 2.

I have:

Utils<ILayoutUtils> iLayoutUtils; that is easy, right now I would like to call its method GetOwnerPageUID as you mentioned earlier, but first argument (as it is in documentation) is const IHierarchy *pageItemHier. I Have tried to do this:

iLayoutUtils->GetOwnerPageUID(IHierarchy::QueryChild(0), kFalse); Iam wondering how to call this method ...


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 Expert ,
Feb 15, 2012 Feb 15, 2012

You should call it like

iLayoutUtils->GetOwnerPageUID(IHierarchy, kFalse);

Where IHierarchy is the interface of the pageitem, if you use querychild then you are moving into the pageitem like for ex in to the image in a pageitem.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php


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 ,
Feb 15, 2012 Feb 15, 2012

Very nice explanation, Thank you a lot!

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 ,
Feb 15, 2012 Feb 15, 2012

Hi Manan,

I have tried to do this:

InterfacePtr<IHierarchy> iHierarchy;

UID abcc = iLayoutUtils->GetOwnerPageUID(iHierarchy, kFalse);

                              resu = abcc.Get();

                              cout << resu;

but the result is 0, even if I have sected frame on page 4 ...

any ideas??

thx

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 Expert ,
Feb 15, 2012 Feb 15, 2012

This works for me fine, maybe the interface that you are sending is not correct. UID 0 represents the document if i remember correctly. See the code that you are using to get the IHierarchy interface.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

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 ,
Feb 15, 2012 Feb 15, 2012

Iam using this piece of code: 

InterfacePtr<IHierarchy> iHierarchy;

dont know, how to get this interface pointer ...

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 Expert ,
Feb 15, 2012 Feb 15, 2012

This would return a null interface as you did not query the interface from any boss class, you need to get this interface from the selected pageitem's boss class.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

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 ,
Feb 15, 2012 Feb 15, 2012

Ok, the selection would be some frame, so what is the best boss to get interface pointer? What about selection manager?

SelectionManager* iSelectionManager = iSelectionUtils->GetActiveSelection();

 

                    if (iSelectionManager != nil)

                    {

                              InterfacePtr<ISTSuite> mySuite(iSelectionManager, UseDefaultIID());

                              InterfacePtr<IHierarchy> iHierarchy(iSelectionManager, UseDefaultIID());

or is there anything that iam missing?

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 Expert ,
Feb 15, 2012 Feb 15, 2012

If you are writing this code inside the CSB method then you can query for "ILayoutTarget" interface that has "GetUIDList" method which will give you the UIDList of the selected page item. From this you can get the UIDRef of the selected pageitem, which can be quried to get the correct iHierarchy interface.

If you are writing this code outside CSB method then write a method in the CSB to get the UIDRef of the selected page item and do as before.

Hope this is not very confusing.

Manan Joshi

- Efficient InDesign Solutions -

MetaDesign Solutions

http://metadesignsolutions.com/services/indesign-development.php

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 ,
Feb 15, 2012 Feb 15, 2012

I have this:

void STSuiteCSB::GetSelectionPage(K2Vector<PMReal> &result)

{

  InterfacePtr<IGeometry> iGeometrySuite(this, UseDefaultIID());

          if (iGeometrySuite == nil) {

  ASSERT_FAIL("Error");

          }

 

  InterfacePtr<ILayoutTarget> iTarget(this, UseDefaultIID());

          if (iTarget == nil) {

  ASSERT_FAIL("Error in iTarget");

  cout << "Error in iTarget";

          }

  UIDList selectionList = iTarget->GetUIDList(kStripStandoffs , kDontStripIfParentLocked);

          UIDRef item = selectionList.GetRef(0);

  cout << "Number of items in seleciton list:";

          cout << selectionList.Length() + "\n";

 

  InterfacePtr<IHierarchy> iHierarchy(item, UseDefaultIID());

}

from this i cannot get anything useful ...

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 Expert ,
Feb 16, 2012 Feb 16, 2012

This works for me fine, don't you get the correct no of selected items? What is the result of GetPageUID. You could also check the boss class of the IHierarchy interface you are using to be sure that it is indeed of the pageitem.

Manan Joshi

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 ,
Feb 16, 2012 Feb 16, 2012

No I dont get any number of selected items, I could select as much items as i want and still get nothing ... list.Length() returns nothing..

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