Copy link to clipboard
Copied
Is that possible to create Shape in Marquee Tool ?
Step 1:- Select Marquee Tool
Step 2:- Automatic Create Shape in scripts How much want this shape
It's automatic making shape through Marquee tool... Thanks in Advance
1 Correct answer
Reviewing the print;
Maybe he tries to add four shapes within the selection divided by two columns and two rows. If it's green, I have an adaptation of a @Chuck Uebele script here...
#target photoshop;
app.bringToFront();
main()
function main(){
app.bringToFront();
var row = 2;
var column = 2;
var ldivision =10;
var corner = 5;
app.preferences.rulerUnits = Units.PIXELS; //new
if(app.documents.length>0){
var doc = activeDocument;
try{
var doc = ac
...
Explore related tutorials & articles
Copy link to clipboard
Copied
The marquee tool does NOT create shapes. It is a selection tool only.
Instead use one of the Shape tools. See screenshot.
Copy link to clipboard
Copied
I Know But , I want Selection the Area By Marquee tool and create shape Automatic,
Is that possible to divided pixel of Marquee tool ?
Copy link to clipboard
Copied
Your question makes no sense.
To create shapes, you must use one of the Shape Tools -- rectangle, elipse, polygon, line or custom...
Marquee is NOT a shape tool. It's a SELECTION tool.
Use the right tools for the job.
Copy link to clipboard
Copied
He marked 'Actions and scripting' label. Anyway he never appreciates our help by proper feedback.
Copy link to clipboard
Copied
Hello Nancy, This question may be off-topic, but... I am a new PS user I am using PS 22.4.2 on a Windows 10 PC. I do not have a Rounded Rectangle Tool available on my toolbar. How can I enable this tool?
Walter in Davie, FL
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks!
Walter in Davie, FL
Copy link to clipboard
Copied
If you ever will script you can't choose Rounded Rectangle Tool from now on, but you can record a code of its use by Script Listener plugin on canvas and still use in latter releases...
Copy link to clipboard
Copied
Hi there,
You may raise a feature request for it here: Adobe Photoshop Family. This forum is directly monitored by our product team and they might look into it. Thanks!
Regards,
Sahil
Copy link to clipboard
Copied
It is possible through the Script Event Manager.
But this is not convenient and difficult. In addition, you will lose the main functionality of the tool.
And in general, why is this necessary?
Easier to call a script or action
Copy link to clipboard
Copied
Please Modify the script ,
1:- Marquee tool Select Area
2:- Create Shape in if i have enter row and column
unSaved();
function unSaved() {
try {
activeDocument.path;
/* Finish Unsaved Document Error Check - Part A: Try */
/* Main Code Start */
if (app.documents.length > 0) {
var originalUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// document;
var myDocument = app.activeDocument;
var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var thePath = myDocument.path;
var theCopy = myDocument.duplicate("copy", false);
// Original X input
var theXinput = prompt("Enter the number of columns across:", 2);
// Remove anything that is not a digit or full point
var theXinputCleaner = theXinput.replace(/[^\d\.]/, '');
// Convert to integer
var theXtoInteger = parseInt(theXinputCleaner, 10);
// Final result
var theX = theXtoInteger;
// Original Y input
var theYinput = prompt("Enter the number of rows down:", 2);
// Remove anything that is not a digit or full point
var theYinputCleaner = theYinput.replace(/[^\d\.]/, '');
// Convert to integer
var theYtoInteger = parseInt(theYinputCleaner, 10);
// Final result
var theY = theYtoInteger;
// Canvas Division
var xFrac = myDocument.width / theX;
var yFrac = myDocument.height / theY;
// psd options;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = true;
psdOpts.layers = true;
psdOpts.spotColors = true;
// create folder;
var folderName = thePath + "/" + theName + "_" + theX + "x" + theY;
if (Folder(folderName).exists == false) {
Folder(folderName).create()
};
//save jpgs;
for (var n = 1; n <= theY; n++) {
for (var m = 1; m <= theX; m++) {
cropTo((m - 1) * xFrac, (n - 1) * yFrac, m * xFrac, n * yFrac);
var theNewName = theName + "_" + bufferNumberWithZeros(m, 3) + "_" + bufferNumberWithZeros(n, 3);
theCopy.saveAs((new File(folderName + "/" + "_" + theNewName + ".psd")), psdOpts, true);
theCopy.activeHistoryState = theCopy.historyStates[0];
}
};
theCopy.close(SaveOptions.DONOTSAVECHANGES);
// reset;
app.preferences.rulerUnits = originalUnits;
};
////// buffer number with zeros //////
function bufferNumberWithZeros(number, places) {
var theNumberString = String(number);
for (var o = 0; o < (places - String(number).length); o++) {
theNumberString = String("0" + theNumberString)
};
return theNumberString
};
////// crop //////
function cropTo(x1, y1, x2, y2) {
// =======================================================
var desc7 = new ActionDescriptor();
var desc8 = new ActionDescriptor();
var idPxl = charIDToTypeID("#Pxl");
desc8.putUnitDouble(charIDToTypeID("Top "), idPxl, y1);
desc8.putUnitDouble(charIDToTypeID("Left"), idPxl, x1);
desc8.putUnitDouble(charIDToTypeID("Btom"), idPxl, y2);
desc8.putUnitDouble(charIDToTypeID("Rght"), idPxl, x2);
var idRctn = charIDToTypeID("Rctn");
desc7.putObject(charIDToTypeID("T "), idRctn, desc8);
desc7.putUnitDouble(charIDToTypeID("Angl"), charIDToTypeID("#Ang"), 0.000000);
desc7.putBoolean(charIDToTypeID("Dlt "), false);
desc7.putEnumerated(stringIDToTypeID("cropAspectRatioModeKey"), stringIDToTypeID("cropAspectRatioModeClass"), stringIDToTypeID("pureAspectRatio"));
desc7.putBoolean(charIDToTypeID("CnsP"), false);
executeAction(charIDToTypeID("Crop"), desc7, DialogModes.NO);
};
alert('PSD Files saved to: ' + folderName);
/* Main Code Finish */
/* Start Unsaved Document Error Check - Part B: Catch */
} catch (err) {
alert('An image must be both open and saved before running this script!')
}
}
/* Finish Unsaved Document Error Check - Part B : Catch */
Copy link to clipboard
Copied
Is that possible to create Shape in Marquee Tool ?
By MXKS
- I am not a scripter, but to do it without scripts, draw your rectangle marquee selection(s)
- In the Paths panel, convert to a path
- With the path selected, go to Edit > Define Custome Shape and give it a name.
~ Jane
Copy link to clipboard
Copied
I don't know why you need it, but here's:
#target photoshop
var s2t = stringIDToTypeID,
t2s = typeIDToStringID;
try { var target = t2s(arguments[1]) } catch (e) { }
try {
if (target) {
(r = new ActionReference()).putProperty(s2t('property'), p = s2t('tool'));
r.putEnumerated(s2t('application'), s2t('ordinal'), s2t('targetEnum'));
var tool = t2s(executeActionGet(r).getEnumerationType(s2t('tool')));
if (tool == 'marqueeRectTool') {
(r = new ActionReference()).putClass(s2t('path'));
(d = new ActionDescriptor()).putReference(s2t('null'), r);
(r1 = new ActionReference()).putProperty(s2t('selectionClass'), s2t('selection'));
d.putReference(s2t('from'), r1);
executeAction(s2t('make'), d, DialogModes.NO);
(r = new ActionReference()).putClass(s2t('contentLayer'));
(d = new ActionDescriptor()).putReference(s2t('null'), r);
(d1 = new ActionDescriptor()).putObject(s2t('color'), s2t('RGBColor'), new ActionDescriptor());
(d2 = new ActionDescriptor()).putObject(s2t('type'), s2t('solidColorLayer'), d1);
d.putObject(s2t('using'), s2t('contentLayer'), d2);
executeAction(s2t('make'), d, DialogModes.NO);
(r = new ActionReference()).putProperty(s2t('channel'), s2t('selection'));
(d = new ActionDescriptor()).putReference(s2t('null'), r);
d.putEnumerated(s2t('to'), s2t('ordinal'), s2t('none'));
executeAction(s2t('set'), d, DialogModes.NO);
}
} else {
app.notifiersEnabled = true
var f = File($.fileName)
app.notifiers.add('setd', f, 'Chnl')
}
} catch (e) { alert(e) }
* save the script to disk and run. On first launch, it will create an event listener and then track the creation of the selection with the marqueeRectTool.
** you can manually remove the event listener menu: file -> scripts -> script event manager
Copy link to clipboard
Copied
It's not working , I want select Marquee tool and create shape if i have enterd row and column
Copy link to clipboard
Copied
OK. I misunderstood you.
Copy link to clipboard
Copied
Reviewing the print;
Maybe he tries to add four shapes within the selection divided by two columns and two rows. If it's green, I have an adaptation of a @Chuck Uebele script here...
#target photoshop;
app.bringToFront();
main()
function main(){
app.bringToFront();
var row = 2;
var column = 2;
var ldivision =10;
var corner = 5;
app.preferences.rulerUnits = Units.PIXELS; //new
if(app.documents.length>0){
var doc = activeDocument;
try{
var doc = activeDocument;
var sBounds = doc.selection.bounds;
var lineAdjW = ldivision/row
var lineAdjH = ldivision/column
var sWidth = (parseFloat(sBounds[2]) -parseFloat(sBounds[0]))/column - ldivision + ldivision/(row ); //modified
var sHeight = (parseFloat(sBounds[3]) -parseFloat(sBounds[1]))/row - ldivision + ldivision/(column ) ; //modified
var leftSide = parseFloat (sBounds[0]);
var topSide = parseFloat (sBounds[1]);
for(var i=0;i<row;i++){
leftSide = parseFloat (sBounds[0]);
for(var j=0;j<column;j++){
Create_Rectangle (topSide, leftSide, topSide + sHeight, leftSide + sWidth, corner) //old code
leftSide += sWidth + ldivision
}
topSide += sHeight +ldivision
}
}
catch(e){}
}
else {alert("There is no open document!")}
function Create_Rectangle(t,l,b,r, corner) {
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(sTID("contentLayer"));
desc1.putReference(cTID("null"), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID("Rd "), 0);
desc4.putDouble(cTID("Grn "), 0);
desc4.putDouble(cTID("Bl "), 0);
desc3.putObject(cTID("Clr "), sTID("RGBColor"), desc4);
desc2.putObject(cTID("Type"), sTID("solidColorLayer"), desc3);
var desc5 = new ActionDescriptor();
desc5.putInteger(sTID("unitValueQuadVersion"), 1);
desc5.putUnitDouble(cTID("Top "), cTID("#Pxl"), t );
desc5.putUnitDouble(cTID("Left"), cTID("#Pxl"), l );
desc5.putUnitDouble(cTID("Btom"), cTID("#Pxl"), b );
desc5.putUnitDouble(cTID("Rght"), cTID("#Pxl"), r );
desc5.putUnitDouble(sTID("topRight"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("topLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomRight"), cTID("#Pxl"), corner);
desc2.putObject(cTID("Shp "), cTID("Rctn"), desc5);
desc1.putObject(cTID("Usng"), sTID("contentLayer"), desc2);
executeAction(cTID("Mk "), desc1, DialogModes.NO);
}
}
Copy link to clipboard
Copied
Thanks @Shulipa Bernad ,It's Worked
Copy link to clipboard
Copied
Can I Change Different color in each shape
Copy link to clipboard
Copied
Can I Change Different color in each shape
By MXKS
I believe it is possible to add the respective color to each shape automatically but I have not been able to do that.
Copy link to clipboard
Copied
Ok Sir @Shulipa Bernad Thanku so much for help
Copy link to clipboard
Copied
It's gave one color only , can you modify the scripts ?
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
// in case we double clicked the file
app.bringToFront();
var sColor = getFillColor();
for( var i = 0; i < app.activeDocument.layers.length; i++ )
{
app.activeDocument.activeLayer = app.activeDocument.layers[i];
if( getFillColor().rgb.hexValue == sColor.rgb.hexValue )
setColorOfFillLayer( app.foregroundColor );
}
function setColorOfFillLayer( sColor ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID('contentLayer'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
var fillDesc = new ActionDescriptor();
var colorDesc = new ActionDescriptor();
colorDesc.putDouble( charIDToTypeID('Rd '), sColor.rgb.red );
colorDesc.putDouble( charIDToTypeID('Grn '), sColor.rgb.green );
colorDesc.putDouble( charIDToTypeID('Bl '), sColor.rgb.blue );
fillDesc.putObject( charIDToTypeID('Clr '), charIDToTypeID('RGBC'), colorDesc );
desc.putObject( charIDToTypeID('T '), stringIDToTypeID('solidColorLayer'), fillDesc );
executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
}
function getFillColor(){
var ref = new ActionReference();
ref.putEnumerated( stringIDToTypeID( "contentLayer" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
var ref1= executeActionGet( ref );
var list = ref1.getList( charIDToTypeID( "Adjs" ) ) ;
var solidColorLayer = list.getObjectValue(0);
var color = solidColorLayer.getObjectValue(charIDToTypeID('Clr '));
var fillcolor = new SolidColor;
fillcolor.rgb.red = color.getDouble(charIDToTypeID('Rd '));
fillcolor.rgb.green = color.getDouble(charIDToTypeID('Grn '));
fillcolor.rgb.blue = color.getDouble(charIDToTypeID('Bl '));
return fillcolor;
}
Copy link to clipboard
Copied
To be honest I didn't understand anything!
If you only need two rows and two columns in the selection, I've improvised a method that might help you.
#target photoshop;
app.bringToFront();
main()
function main(){
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
var row = 2;
var column = 2;
var ldivision =10;
var corner = 5;
app.preferences.rulerUnits = Units.PIXELS; //new
if(app.documents.length>0){
var doc = activeDocument;
try{
var doc = activeDocument;
var sBounds = doc.selection.bounds;
var lineAdjW = ldivision/row
var lineAdjH = ldivision/column
var sWidth = (parseFloat(sBounds[2]) -parseFloat(sBounds[0]))/column - ldivision + ldivision/(row ); //modified
var sHeight = (parseFloat(sBounds[3]) -parseFloat(sBounds[1]))/row - ldivision + ldivision/(column ) ; //modified
var leftSide = parseFloat (sBounds[0]);
var topSide = parseFloat (sBounds[1]);
for(var i=0;i<row;i++){
leftSide = parseFloat (sBounds[0]);
for(var j=0;j<column;j++){
Create_Rectangle (topSide, leftSide, topSide + sHeight, leftSide + sWidth, corner) //old code
leftSide += sWidth + ldivision
}
topSide += sHeight +ldivision
}
colorShape(196, 0, 0); targetLayer("Bckw"); colorShape(9, 1, 195);
targetLayer("Bckw"); targetLayer("Bckw"); colorShape(1, 196, 15);
}
catch(e){}
}
else {alert("There is no open document!")}
function Create_Rectangle(t,l,b,r, corner) {
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putClass(sTID("contentLayer"));
desc1.putReference(cTID("null"), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
var desc4 = new ActionDescriptor();
desc4.putDouble(cTID("Rd "), 0);
desc4.putDouble(cTID("Grn "), 0);
desc4.putDouble(cTID("Bl "), 0);
desc3.putObject(cTID("Clr "), sTID("RGBColor"), desc4);
desc2.putObject(cTID("Type"), sTID("solidColorLayer"), desc3);
var desc5 = new ActionDescriptor();
desc5.putInteger(sTID("unitValueQuadVersion"), 1);
desc5.putUnitDouble(cTID("Top "), cTID("#Pxl"), t );
desc5.putUnitDouble(cTID("Left"), cTID("#Pxl"), l );
desc5.putUnitDouble(cTID("Btom"), cTID("#Pxl"), b );
desc5.putUnitDouble(cTID("Rght"), cTID("#Pxl"), r );
desc5.putUnitDouble(sTID("topRight"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("topLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomLeft"), cTID("#Pxl"), corner);
desc5.putUnitDouble(sTID("bottomRight"), cTID("#Pxl"), corner);
desc2.putObject(cTID("Shp "), cTID("Rctn"), desc5);
desc1.putObject(cTID("Usng"), sTID("contentLayer"), desc2);
executeAction(cTID("Mk "), desc1, DialogModes.NO);
}
function targetLayer(method){
var d = new ActionDescriptor();
var r = new ActionReference();
r.putEnumerated(app.charIDToTypeID("Lyr "), app.charIDToTypeID("Ordn"), app.charIDToTypeID(method));
d.putReference(app.charIDToTypeID("null"), r);
var list1 = new ActionList();
d.putList(app.charIDToTypeID("LyrI"), list1);
executeAction(app.charIDToTypeID("slct"), d, DialogModes.NO);
}
function colorShape(Rd, Grn, Bl){
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(sTID("contentLayer"), cTID('Ordn'), cTID('Trgt'));
desc1.putReference(cTID('null'), ref1);
var desc2 = new ActionDescriptor();
var desc3 = new ActionDescriptor();
desc3.putDouble(cTID('Rd '), Rd);
desc3.putDouble(cTID('Grn '), Grn);
desc3.putDouble(cTID('Bl '), Bl);
desc2.putObject(cTID('Clr '), sTID("RGBColor"), desc3);
desc1.putObject(cTID('T '), sTID("solidColorLayer"), desc2);
executeAction(cTID('setd'), desc1, DialogModes.NO);
};
}
Copy link to clipboard
Copied
Thanku so much sir !
Copy link to clipboard
Copied
Suppose I will to put 3row and 3column, I have seen 4 shape only color , And Many shape is black


-
- 1
- 2