Article View: adobe.scripting.indesign
Article #9795Re: Variation of Dave's Script in "How To Begin Scripting"
From: Dave_Saunders
Date: Tue, 18 Jul 2006 02:15
Date: Tue, 18 Jul 2006 02:15
40 lines
2285 bytes
2285 bytes
It didn't occur to me to return a reference when I wrote the addAnchor() method. Let me see:
InsertionPoint.prototype.addAnchor = function() {
var aDoc = app.documents[0];
var anchProps = aDoc.anchoredObjectDefaults.properties;
var anchCont = anchProps.anchorContent;
// Make new object with correct default settings
if (anchCont == ContentType.unassigned) {
var myAO = this.rectangles.add();
} else {
var myAO = this.textFrames.add();
}
// Make new object right kind of object
myAO.contentType = anchCont;
// Recompose parent story so geometricBounds make sense
this.parentStory.recompose();
//save users measurement preferences
userHoriz = aDoc.viewPreferences.horizontalMeasurementUnits;
userVert = aDoc.viewPreferences.verticalMeasurementUnits;
aDoc.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
aDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
var myBds = myAO.geometricBounds;
myBds[0] = myBds[2] - anchProps.initialAnchorHeight;
myBds[3] = myBds[1] + anchProps.initialAnchorWidth;
myAO.geometricBounds = myBds;
aDoc.viewPreferences.horizontalMeasurementUnits = userHoriz
aDoc.viewPreferences.verticalMeasurementUnits = userVert
myAO.applyObjectStyle(anchProps.anchoredObjectStyle);
if (anchProps.anchorContent == ContentType.textType) {
try { // might be null
myAO.parentStory.appliedParagraphStyle = anchProps.anchoredParagraphStyle;
} catch (e) {}
}
myAO.anchoredObjectSettings.properties = aDoc.anchoredObjectSettings.properties;
return myAO
}
Well, that was easy. I think that'll work.
Dave
Technical Details
Message-ID:
<3bc0ed94.12@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!newsfeed.freenet.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc0ed94.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,c3f000112de732ba X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: Dave_Saunders@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: Variation of Dave's Script in "How To Begin Scripting" Message-ID: <3bc0ed94.12@webcrossing.la2eafNXanI> Date: Mon, 17 Jul 2006 19:15:18 -0700 References: <3bc0ed94.-1@webcrossing.la2eafNXanI> Lines: 45 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!newsfeed.freenet.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing