Skip to main content
Known Participant
March 20, 2024
Question

How can I resize graphic with attribute?

  • March 20, 2024
  • 1 reply
  • 3685 views

hello.

I have a question about scripting to resize graphic.

This is the script to resize graphic

 

doc = app.ActiveDoc;

graphicObj = doc.FirstGraphicInDoc;

while(graphicObj.ObjectValid()) {

graphicObj = graphicObj.NextGraphicInDoc;

if(graphicObj.type == Constants.FO_Inset) {

name = graphicObj.InsetFile;

graphicObj.InsetDpi=300;

}

}

but I want to resize graphic only having attribute placement "break"
How can I do this with script??

This topic has been closed for replies.

1 reply

frameexpert
Community Expert
Community Expert
March 20, 2024
var element, value;

element = graphicObj.Element;
value = getAttributeValue (element, "break");

function getAttributeValue (element, name) {
    
	/// value = getAttributeValue (element, name);
	
    var attrList = element.Attributes, i = 0;
    
    for (i = 0; i < attrList.length; i += 1) {
        if (attrList[i].name === name) {
            if (attrList[i].values[0] !== undefined) {
                return (attrList[i].values[0]);
            }
        }
    }
}
Known Participant
March 21, 2024

hello.
I tried but It is not working.

On ESTK, I can see there is the problem.

 

var attrList = element.Attributes, i = 0;

 

but I don't think it is only reason about it.
maybe my script is basically focus on graphic object and it seems like it doesn't have attribue because
it is not an element.
should I find out script with another way for resize the image?




frameexpert
Community Expert
Community Expert
March 21, 2024

Is your document structured? Can you send a screenshot of the Structure View at the image element? Thanks.