AIArtSuite::GetArtBounds

I try to use AIArtSuite::GetArtBounds to get the bounds of an art, but the result is different than the bounds data in Transform panel. Why?
Does the result of AIArtSuite::GetArtBounds uses pixel unit? and how to get the same result as in Transform panel?I need the object's width in mm unit.
Thanks.

All coordinate information obtained from the API is in points/pixels (which equate to the same numeric values). Similarly, any values you send to the API should likewise be in points or pixels.
Additionally, there are a number of flags that can be set when getting the art bounds. You should look at the AIArtSuite::GetArtTransformBounds() call, and it's associated flags (AIArtBoundsOptions), both found in AIArt.h. The GetArtBounds() call is basically a wrapper around GetArtTransformBounds() that always uses some default flags (I forget which, but it's not hard to figure out).
Hope that helps!

Similar Messages

  • How do I copy an art object from one document to another using illustrator API(C  )

    Hi, I'm trying to copy text and graphic elements from one document into another, does anybody has an idea how to do it using Illustrator SDK(C++)?
    Thanks in advance.

    If you call AIArtSuite::ReorderArt() giving the layer group handle from the target document and using art from the source document, it will move art between documents. That said, there are all sorts of caveats that come along with that -- some things move over automatically (graphic styles, symbols) while others cause problems. E.g. copying art that contains a swatch can cause a crash when you shut down the source document because it may keep the style reference to the swatch in the source document -- which goes away when the document is closed. Gradients in particular are a problem I believe. Straight up colours are (I think) fine. I've had to write a lot of workarounds for various headaches caused by moving art between documents.
    Bottom line: its very doable, but there are a lot of edge cases. This was clearly not an intended use of the SDK, though it is possible.

  • Align to pixel grid

    Hi all,
    My plugin uses AIShapeConstructionSuite for creating geometric shapes.
    I don't want them to be aligned to the pixel grid, they are however when "Align new objects to pixel grid" is enabled in the current document.
    Is there any way to disable this from the SDK?
    Thanks.

    Found it, apparently it has to do with the pixel-perfect mode of an art object, which can be set with AIArtSuite.

  • How to set/get visibility of an art of an artset ?

    hi,
    while trying to rasterize the layer,
    if a layer is invisible and it's art are visible then only I can able to get the arts in the raster but if arts are invisible of a layer irrespective of visibility of their layer, I am unable to get the invisible art in the  raster.
    Is there any function in API(CS4) which can get/set visibility of an art of a layer?
    how can I do so?
    can anybody help me in concern of above?
    thanks
    Deep Alone.

    oh wow!!! I just got the answer.
    It can be done by using function  GetArtUserAttr( ) of  AIArtSuite (AIArt.h).
    thanks anyway.

  • CS3 SDK plugin won't load in CS2

    Hello,
    Looking at the Illustrator SDK programmer's guide is looks like it should be possible to develop a universal binary plugin using XCode. It appears that its possible to use this universal binary plugin with both CS2 and CS3. When I compile the sample plugins that come with CS3 SDK, they will not load in CS2. "Error loading plugins" This is on an intel mac running 10.4.9. Could anyone shed some light on this situation for me? Do I have to develop two plugins? Does Illustrator output a debug log anywhere which would help me understand what's going on?

    Jon, yes it is possible to do this (i.e. develop a universal binary plug-in using Xcode that loads and runs under Illustrator CS2 and CS3). There are two reasons why the universal binaries for samples from the CS3 SDK don't load and run under CS2.
    1) CS2 can't find their plug-in entry point function.
    2) The CS3 SDK samples are dependent on versions of suites that are only available in CS3.
    Regarding 1 - CS2 will use the entry point function name provided in the 'mach' property in your plug-in's PiPL resource. If the function name provided there is empty CS2 will look for a function named "main" and call that if it is available, otherwise you'll get an "Error loading plug-ins." alert. The behaviour of CS3 is slightly different, if the entry point name is empty it looks first for a function named "PluginMain", then for a function named "main", then gives up with the error alert. The CS3 samples all use an entry point function named "PluginMain" and leave the entry point name empty in their 'mach' property (and their 'mi32' property for that matter). It's straightforward to change this. For example, to name the entry point for the Tutorial sample on the CS3 SDK add the commented line below to Tutorial.r:
    #define PIPL_PLUGIN_NAME "Tutorial"
    #define PIPL_ENTRY "PluginMain" // add this line
    #include "Plugin.r"
    Regarding 2 - to have a plug-in that will successfully run under CS2 or CS3 the plug-in must only depend on suites that are available under the host application. The simplest arrangement is to have one plug-in binary that uses the suite versions supported by CS2 - the "lowest common denominator" approach. Alternatively your plug-in can make a run time check of the version of Illustrator it is running under and acquire / use the suite versions appropriately. The CS3 SDK samples don't do either of these things. So if you only make the fix for 1 described above in the Tutorial sample it will still fail to load under CS2 because it will try and acquire suites that are only available in CS3. If you change the Tutorial sample to use the legacy suite versions supported by CS2 (such as AIArtSuite, AIPathSuite,AIDocumentViewSuite, AIUnicodeStringSuite and AIToolSuite whose headers you'll find in the AI120xxx header files in the legacy folder on the CS3 SDK) you can implement a lowest common denominator approach for the sample and it should at least startup cleanly under CS2. There may be further changes required to get all the features of the sample to run properly.
    I haven't had much luck getting the Xcode 2.4.1 debugger to host a debug session under Illustrator CS2 - so debugging is painful. But it may well be my own lack of Xcode / gdb knowledge that's the barrier here.

  • Envelope distort with Mesh

    Hi,
    I am trying to create an envelope distort based on a grid mesh within a LiveEffect similar to Envelope distort--> Make with mesh. Given the path shape "art" I create a grid kmeshArt based on its bounding box:
    result = sAIArt->NewArt(kMeshArt,kPlaceAboveAll, nil,&myEnvelopeMesh);
    sAIMesh->InitCartesian(myEnvelopeMesh,width_i,height_j);
    result = sAIArt->GetArtBounds(art, &artBounds);
    //get the corners of the bounding art A,B,C,D, in clokwise order starting at top-left corner.
                                  pointA.h=artBounds.left;
                                  pointA.v=artBounds.top;
                                  pointB.h=artBounds.right;
                                  pointB.v=artBounds.top;
                                  pointC.h=artBounds.right;
                                  pointC.v=artBounds.bottom;
                                  pointD.h=artBounds.left;
                                  pointD.v=artBounds.bottom;
    Now via setpoint and a segment iterator I assign the values to  the four segments of the grid to match the art's bounding box:
    sAIMeshSegmentIterator->SetPoint(segment,0, &pointA); //top left corner point
    pointTMP.h=pointA.h+boundSize.h;
    pointTMP.v=pointA.v;
    sAIMeshSegmentIterator->SetPoint(segment,1, &pointTMP);     //horizontal handle
    pointTMP.h=pointB.h-boundSize.h;
    pointTMP.v=pointB.v;
    sAIMeshSegmentIterator->SetPoint(segment,2, &pointTMP);      //horizontal handle of next point
    sAIMeshSegmentIterator->SetPoint(segment,3, &pointB);
    sAIMeshSegmentIterator->NextOnPatch(segment,kAIMeshCounterClockwise); //top right corner
    I tried to create the envelope object by assigning the mesh a envelopeObject (second parameter) but it doesn't work.
    result = sAIEnvelopeSuite->MakeEnvelope(&art,1,myEnvelopeMesh,&eOptions,&myEnvelope);
    In fact, a call to sAIEnvelopeSuite->GetEnvelopeType(myEnvelope, &EnvType) reveals that it is of type kEnvelopeObject and not kEnvelopeMesh.
    So what I did was the following:
    result = sAIEnvelopeSuite->MakeEnvelope(&art,1,nil,&eOptions,&myEnvelope);
    result= sAIEnvelopeSuite->SetEnvelopeObject(myEnvelope, myEnvelopeMesh);
    In this case the envelope appears where it should be (when expanding the liveEffect object) but it has already distorted the shape within ("art"). If I manually restart the shape (by pressing the button "Reset Envelope Shape")  then it removes the original distortion of the enveloped shape and you can edit it perfectly by moving the vertices of the meshgrid, which behave as expected.
    In the image the (translucent white gradient) star should be aligned with the star behind, but it gets distorted (left) until envelope is reset (right).
    Why is this happening?  Is it because is created within a live effect? Maybe I am making a bad definition of the mesh grid or SetEnvelopeObject  is not properly used...
    Thanks,
    Jorge.

    You are using the the selection tool which will not allow you to grab a handle. So change to the direct select (the white arrow) tool and you will be much happier.

  • XML support in AI

    Hi,
    I know there's XML support for InDesign but what abt AI? What I need to do is XML coding and tagging. Anyone?

    Look at the public API on the SDK - http://www.adobe.com/devnet/illustrator/sdk/
    In particular:
    AIArtSuite - Get/Set XMP metadata for an art object.
    AIDocumentSuite - Get/Set XMP metadata for a document object.
    AIAssetMgmtSuite - Simple XMP metadata manipulation.
    And AIXMPDataFieldMap - the structure used to update XMP metadata.

  • How to group arts into a group

    I look in AIArtSuite but could not figure out how to group multiple arts into a group.
    Please help.

    Thanks very much, this is how I ended up doing:
    There are 2 arts to be grouped: image (kPlacedArt) and path (kPathArt).
    I created a new art of type kGroupArt and place the other two inside it.
        sAIArt->NewArt(kGroupArt, kPlaceAboveAll, nil, &group);
        sAIArt->ReorderArt(image, kPlaceInsideOnTop, group);
        sAIArt->ReorderArt(path, kPlaceInsideOnTop, group);

  • How to convert a text object to a Group?

    There are some text object present on Adobe Illustrator document. Each text object is required to convert in individual group, so that some entities can be inserted under those objects turned groups.
    In the APIs available with AI SDK, there can not be found an API to have the conversion directly. There is a provision of 'ReleaseToLayer' but it will not serve the purpose.
    Will it be possible to have such coversion?
    OR
    It will also do, if a Group is created and the text object is able to be moved under the Group.
    Is there any API to create a 'Group' ?

    I'm not quite following what you're trying to do exactly, but I'm sure there's a way to do it.
    You can create a group using the AIArtSuite (NewArt). You can iterate through a text object using the objects found in IText.hpp. You can load an IText object using the functions in AITextFrame.h (usually GetATETextRange). If you're trying to break up parts of text into separate groups, you'll have to do that manually using these APIs. If that's not what you're trying to do, I'm afraid I'm just not understanding your explanation; maybe you can try and clarify it.

  • Get notified when art object is deleted or added

    Hi, anyone know how to get notified when user added or deleted an art object?
    I searched the SDK in and out and found nothing.
    Thanks,
    Don

    If you have art you wish to keep track of, the way to do it is using ArtUIDRefs (AIUID.h). You can ask art for a unique identifier and later on ask for the handle that belongs to that UID. Its not too hard at that point to determine if it still exists or not. Note that you will probably need to use AIArtSuite::ValidArt() if you get a handle back. This tells you if the handle is actually on the canvas or not; handles persist even when deleted becuase the delete could be undone.
    So if you're tracking a small number of particular handles, its quite easy to know whent hey're deleted. If you're trying to watch a huge number of art handles though, you're going to pay a heavy price. While I wish they had better ways to deal with this, the truth is the SDK isn't designed for that kind of plugin. You can make it work, but you're kind of out on the edge of what they'd planned.

  • Highlighting art on document when ArtHandle is known

    I have a list of art (handles) from current document, collected by applying some filter.
    I show a entry in a list box on my plugin panel dialog for each art handle I have selected.
    Now I want to implement a mechanism to highlight the corressponding art, when I select it from the list box (say on double click of the list's entry).
    To highlight I take the approach as
    1. Annotation around the art
    2. Bringing the art in the visible area.
    1. Annotation :
    For annotation I understand we need to have a AIAnnotatorDrawer for "sAIAnnotatorDrawer->DrawRect".
    In the SDK sample, this AIAnnotatorDrawer  is taken from the notifier's message.
    In my case, I don't want any notification, but want to draw the rectangle and then erase it. I know the art's handle, hence can find location and bounds of the art.
    I have acheived it throught "sAIShapeConstructor->NewRect", but this modifies the document's artwork. Hence, was checking the annotator.
    2. Bringing the art to visible area :
    Solution is "AIDocumentViewSuite::SetDocumentViewCenter" ??
    Please help me out with some sample reference / suite for pt#1. And please verify pt#2.
    A totally different way to highlight the art knowing its handle is also welcome.

    The AIDocumentViewSuite has everything you need to center on the selected art. I can't remember off the top of my head, but we've got almost exactly what you're talking about in our plugin and the centering stuff was pretty easy. Just poke through that header, it shouldn't be a problem. Just bear in mind that you might need to use one of its methods to convert from page coordinates to 'view coordinates' (which are basically pixels).
    As for the annotation, that's fairly easy for something like this, so long as you understand annoations. There are several threads on that already, explaining the basics, and if you're not familliar with them I'd go read them first. But assuming you grasp the basics of annotations, here's the high level for what you're looking for:
    Use AIArtSuite::GetBounds() on the handle you want to denote
    Call AIAnnotatorSuite::InvalAnnotationRect() on the bounds from Using the bounds from (1), after converting them into document view coordinates using the AIDocumentViewSuite (very easy).
    Assuming you've registered an annotator with Illustrator, you should get a caller/selector for drawing the annotation. The message will include an AIAnnotatorDrawer, which you'll need to actually draw your mark up.
    Draw whatever it is you want around the art; you'll probably want to cache the art in question so you know what art you're supposed to be marking up.
    One thing to note: to clear the annoation (let's say you can pick nothing on your list) you'd do steps (1) & (2) and you'd just do nothing in (3) or (4). For us, in that situation I just clear the cached handle and then in (3) & (4) I do nothing if the handle is null.
    Additional notes: AIDrawArtSuite::DrawHilite() is a nice method you can use to hilite paths. It works on other types of art, but it looks best on paths.

  • Get bounds only of what is visible?

    Okay, So when you use a clipping mask there can sometimes be a lot of art that is invisible. If you "Select All" you'll get a rectangle only around what's visible.  I want the bounds of that rectangle.
    I tried itterating the art but I don't think that the art type is the best way to figure this one out.  And if you use AIGroupSuite to test if an art group is "clipped" with GetGroupClipped, you get the bounds of the larger art that I'm trying to avoid.
    I didn't see anything about bounds of a "selection" in the docs. 
    Anyone got a hint on where to look for this one?

    you should do this way:
    //Get Art Bounds for each AIArtHandle
    AIRealRect artBounds;
    error = sAIArt->GetArtBounds(*iter, &artBounds);
    aisdk::check_ai_error(error);
    //Compute selection bouding box.
    AIRealRect& boundingBox;
    //for each selected AIArtHandle, bouding box needs to be updated. (loop)
    if(boundingBox.left > artBounds.left)
         boundingBox.left = artBounds.left;
    if(boundingBox.top < artBounds.top)
         boundingBox.top = artBounds.top;
    if(boundingBox.right < artBounds.right)
         boundingBox.right = artBounds.right;
    if(boundingBox.bottom > artBounds.bottom)
         boundingBox.bottom = artBounds.bottom;
    Finally, you will have your selection bounding box.

  • Export sub-layer without its parent content

    Hello,
    I am trying to export the sublayer in jpg without the parent layer's content. I have tried options with AIArtSuite and AILayerSuite but have been unsuccessful. The following is the code for reference:
    sAILayerSuite->GetFirstLayer(&Firstlayer);
    sAILayerSuite->GetLayerFirstChild(Firstlayer, &childLayer);
    sAIArt->GetFirstArtOfLayer(childLayer, &artGroup);
    //Export to jpg using the artGroup
    On observing the layers in AI, the child layer preview always has the content of the parent layer. So,
    Is it possible to get the art of a sublayer without the parents content? If yes, then how to achieve that?
    Thanks,
    Hitesh

    I've tried using the AIRasterizeSuite but still no luck. Here's what i've tried:
    Approach 1:
    //Get the childe layer from the parent
    AILayerSuite->GetLayerFirstChild(Firstlayer, &childLayer);
    Approach 2:
    sAIArt->GetFirstArtOfLayer(Firstlayer, &artGroup);
    sAIArt->GetArtFirstChild(artGroup, &childart);
    sAIArt->GetLayerOfArt(childart, &childLayer);
    And after getting the layer handle in childLayer, the following is used.
    // Create the art set.error = artSetSuite->NewArtSet(&artSet);
    // Populate the art set.
    error = artSetSuite->LayerArtSet(childLayer, artSet);
    //Create raster settingsAIRasterizeSettings rasterSettings;
    rasterSettings.type = kRasterizeRGB;
    //Compute bounds
    AIRealRect bounds;
    error = sAIRasterize->ComputeArtBounds(artSet, &bounds, false); 
    //Create raster
    AIArtHandle rasterOut = NULL;
    error = sAIRasterize->Rasterize( artSet, &rasterSettings, &bounds, kPlaceAboveAll, 0, &rasterOut, MyRasterizeProc);
    But in either case the result is the same, the chaild layer always contains the information of the parent.
    Also, as mentioned in the previous post, I could not find any AIRaster and AIRasterHandle in the SDK. I'm using the CS3 SDK.
    thanks,
    Hitesh

  • Using the XMP Toolkit in Illustrator

    I'm trying to read information from the XMP metadata of a linked image in Illustrator from a Plugin. The SDK doesn't seem to provide a full API for manipulating XMP apart from the ability to obtain the XMP packet from an art object via the AIArtSuite with GetArtXMP(...) etc.
    So naturally I went for Adobe's XMP Toolkit to do the hard work for me, however I've run into some strange issues that have me a little stumped. Basically, no matter what I do, after calling anything from the XMP Toolkit (SXMPMeta), I end up with either a SIGABRT or BAD_ACCESS in a random object destructor such as ai::FilePath or std::string.  I assume this is due to some memory being deallocated too early based on my usage of the toolkit.
    Doing a bit more reading, I see that the XMP Toolkit uses a singleton pattern under the hood. This leads me to believe that there is some conflict with Illustrator's own implementation of the toolkit and my own.
    Could anyone shed any light on this? Is there another way I should be doing this? Any help anyone can give me would be hugely appreciated!
    Thanks!
    -W
    *Edit: I've linked to the XMP Toolkit both statically and dynamically, each time with the same results.
    Another interesting thing I noticed is that if I compile both my plugin and the XMP toolkit with "Symbols Hidden By Default" (GCC_SYMBOLS_PRIVATE_EXTERN) set to "NO", I don't get a crash, but I can't register my namespaces. They just don't appear in the list of namespaces even after dumping the namespace list out directly after the call to SXMPMeta::RegisterNamespace(...)
    Should I be asking in the XMP Toolkit forum?

    Please ignore this post. The problem was in my own code. I was stomping over memory that wasn't mine to stomp over.
    /idiot

  • Get selected art object

    I am trying to get the user selected art object properties, I tried written the code below and realised this get all the objects in the layer and store all of them in the AIArtHandle instead of what I selected. I only want to print out the one user selected, how??? any help???
    AIMatchingArtSuite *aiArtMatch;
    sBasic->AcquireSuite( kAIMatchingArtSuite, kAIMatchingArtSuiteVersion, (const void**)&aiArtMatch );
    AIArtHandle **artStore = NULL;
    long artCount = 0;
    aiArtMatch->GetSelectedArt(&artStore, &artCount);
    AIArtHandle my_artHandle = (*artStore)[0];

    I believe the problem you're having is that selection 'climbs upwards'. That is, if you select some art you also select it's parent, and its parent's parent, etc.
    So even if you just select a single path, you're also selecting the group that represents the layer. As such, you might be able to just ask the art if it's a layer group using AIArtSuite::IsArtLayerGroup() and ignore it if it is. I believe the rest will be an accurate depiction of what's selected, be it on art or many.
    Oh, and if the art you've selected is a compound path, that call will also include all the sub-component paths. If you don't want them, you can also ask each art in your set if it's part of a compound path by using AIArtSuite::GetArtUserAttr() with kArtPartOfCompound; I believe you can ignore anything that has that, though I'm not sure how it responds when you pass it the container kCompoundPathArt.
    Hope that helps!

Maybe you are looking for