Using outer Select tag to Fill Inner Select Tag
I had written a code as follows
Where I have a table in which two of it's cells are Select tags. i want onchange of first Master Select tag the other combo should be filled with values of database. When I have more than one rows in a table the Values are not preserved in the both Select tags as soon as i Select the Master Select Tag[u[/b]]
<table width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor="#C7D3EB" >
<tr>
<th colspan="1"><font size="2" face="Verdana">Sr.No.</font></th>
<th colspan="1"><font size="2" face="Verdana">Expence Catg.</font></th>
<th colspan="1"><font size="2" face="Verdana">Expence Desc.</font></th>
<th colspan="1"><font size="2" face="Verdana">Budget Amt.</font></th>
<th colspan="1"><font size="2" face="Verdana">FIL Share(%)</font></th>
<th colspan="1"><font size="2" face="Verdana">Uesr Remark</font></th>
<th colspan="1"><font size="2" face="Verdana">Mkt. Remark</font></th>
</tr>
<%
if(strentry!=null)
for(int i=1; i<=entry; i++)
%>
<tr>
<td> <font size="2" face="Verdana"><input name="sr_no" value=<%=i%> type="text" size="2" ></font></td>
<td> <font size="2" face="Verdana">
<select name="exp_hd" onchange="Submitme()">
<%
int j=i;
ArrayList expctg = spb.getExpenseCategory();
Iterator ite = expctg.iterator();
while(ite.hasNext())
String exp_catg = (String)ite.next();
%>
<option value="<%=exp_catg%>" <%if(exp_catg.equals(expense_catg) ) out.println("selected"); %>><%=exp_catg%></option>
<%
%>
</select>
</td>
<%
if(expense_catg!=null)
%>
<td> <font size="2" face="Verdana">
<select name="exp_desc">
<%
ArrayList expdesc = spb.getExpenseDesc(expense_catg);
Iterator ited = expdesc.iterator();
while(ited.hasNext())
String exp_desc_cd = (String)ited.next();
String exp_desc = (String)ited.next();
%>
<option value="<%=exp_desc_cd%>" <%if(exp_desc_cd.equals(expense_desc)) out.println("selected"); %>><%=exp_desc%></option>
<%
%>
</select>
<%
%>
<td> <font size="2" face="Verdana"><input name="bud_amt" type="text" size="5" ></font></td>
<td> <font size="2" face="Verdana"><input name="fil_share" type="text" size="5" ></font></td>
<td> <font size="2" face="Verdana"><input name="user_rmk" type="text" size="35" ></font></td>
<td > <font size="2" face="Verdana"><input disabled="true" STYLE="background-color: #FFFFCC;" name="mkt_rmk" type="text" size="35" ></font></td>
</tr>
<%
%>
</tr>In this entry is a variable on which the rows of table are decided.
So whwt i have to do to preserve the values of Options in Select tags
in Previous rows
I had written a code as follows
Where I have a table in which two of it's cells are Select tags. i want onchange of first Master Select tag the other combo should be filled with values of database. When I have more than one rows in a table the Values are not preserved in the both Select tags as soon as i Select the Master Select Tag[u[/b]]
<table width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor="#C7D3EB" >
<tr>
<th colspan="1"><font size="2" face="Verdana">Sr.No.</font></th>
<th colspan="1"><font size="2" face="Verdana">Expence Catg.</font></th>
<th colspan="1"><font size="2" face="Verdana">Expence Desc.</font></th>
<th colspan="1"><font size="2" face="Verdana">Budget Amt.</font></th>
<th colspan="1"><font size="2" face="Verdana">FIL Share(%)</font></th>
<th colspan="1"><font size="2" face="Verdana">Uesr Remark</font></th>
<th colspan="1"><font size="2" face="Verdana">Mkt. Remark</font></th>
</tr>
<%
if(strentry!=null)
for(int i=1; i<=entry; i++)
%>
<tr>
<td> <font size="2" face="Verdana"><input name="sr_no" value=<%=i%> type="text" size="2" ></font></td>
<td> <font size="2" face="Verdana">
<select name="exp_hd" onchange="Submitme()">
<%
int j=i;
ArrayList expctg = spb.getExpenseCategory();
Iterator ite = expctg.iterator();
while(ite.hasNext())
String exp_catg = (String)ite.next();
%>
<option value="<%=exp_catg%>" <%if(exp_catg.equals(expense_catg) ) out.println("selected"); %>><%=exp_catg%></option>
<%
%>
</select>
</td>
<%
if(expense_catg!=null)
%>
<td> <font size="2" face="Verdana">
<select name="exp_desc">
<%
ArrayList expdesc = spb.getExpenseDesc(expense_catg);
Iterator ited = expdesc.iterator();
while(ited.hasNext())
String exp_desc_cd = (String)ited.next();
String exp_desc = (String)ited.next();
%>
<option value="<%=exp_desc_cd%>" <%if(exp_desc_cd.equals(expense_desc)) out.println("selected"); %>><%=exp_desc%></option>
<%
%>
</select>
<%
%>
<td> <font size="2" face="Verdana"><input name="bud_amt" type="text" size="5" ></font></td>
<td> <font size="2" face="Verdana"><input name="fil_share" type="text" size="5" ></font></td>
<td> <font size="2" face="Verdana"><input name="user_rmk" type="text" size="35" ></font></td>
<td > <font size="2" face="Verdana"><input disabled="true" STYLE="background-color: #FFFFCC;" name="mkt_rmk" type="text" size="35" ></font></td>
</tr>
<%
%>
</tr>In this entry is a variable on which the rows of table are decided.
So whwt i have to do to preserve the values of Options in Select tags
in Previous rows
Similar Messages
-
Is there a way of turning this "color range selection" into a normal selection?
Yes
With Color Range there can be stray partially selected pixels all over the place. It best to first make the color range selection and with the selection active switch to the rectangle marquee tool and hold the Alt or option key down and clean up the stray pixel by subtracting large rectangle areas. You will stall have partially select pixels in the area you want solid. You can use a trick I use when I work on layers mask. Layer Mask are grayscale channels. When you paint with Black and White with the brush blend mode set Overlay the white and black areas are protected. Only the gray partially select area will change. So You can save your cleaned up Color Range selection as an Alpha Channel and paint with white to turn the partially select pixels in the Alpha channel to fully selected.
To show how the overlay mode works I could just have saved the color selection as and Alpha channel. Switched to the Channels palette targeted the alpha and cleaned up the selection. I chose to show that overlay blend will even work in RGB mode when you paint Black and White.
After I cleaned up the stray pixels I added a an empty layer on top om the image and filled the selection with black then inverted the selection and filled with white to create a Black and white work layer. Grabbed a black paint brush set overlay mode and repeatedly brushed over the image and drove the gray pixels to black. View screen capture in a new browser tan ans scale it to actual pixels. This sits scale upload images poorly. -
Inner Selects vs. Outer Joins
We have a report where we are joining many tables (25 tables) together. Initially, we created the report with outer joins and noticed that the cost of the explain plan was 2600 and the performance was adequate. We then started to remove the outer joins and replacing with inner selects and the cost and performance of the report improved. Currently, we have replaced 13 of the outer joins with inner selects and the cost is down to 650.
Typically, I have always used joins or outer joins because I thought this was best practice. However, I am now questioning this.
Is it better to use inner selects when you are only returning one column from a table?
Other than tables that require multiple columns to be returned, are there issues we should be concerned with?
Below are examples:
Thanks,
Brian
-- Using Outer Joins
Select q.quote_id, q.quote_name, l.location_name, sr.sales_rep_name
from quote q, location l, sales_rep sr
where q.location_id = l.loation_id (+)
and q.sales_rep_id = sr.sales_rep_id (+)
-- Using Inner Selects
Select q.quote_id, q.quote_name,
(select location_name from location where location_id = q.location_id) location_name,
(select sales_rep_name from sales_rep where sales_rep_id = q.sales_rep_id) sales_rep_name
from quote qThe cost of a query does not mean better performance. The scalar subqueries that you use when rewriting that query show up in your explain plan with no cost at all, and this is just no true. (a query must "cost" something, right?)
Instead of starting to rewrite your queries using scalara subqueries, it's better to investigate why a query performs bad.
If using scalar subquery would always yield a better performance, Oracle would probably rewrite all outer join queries to using scalar subquery. -
Inner select and select in "record selection"- Formula workshop problem
Hi,
I am facing a bit tough situation in creating a Crystal Report.
I have two queries which I need to accommodate in the Report according to a given parameter (selectionParameter).
The queries are as follows:
select total, minvalue, customer
(select sum(A) TOTAL, min(B) minValue, C customer
from table1, table2
where table1.A = table2.E
AND B in (Select B from table3 where F=10)
group by C
order by total, minValue
select total, minvalue, customer
(select sum(A) TOTAL, min(B) minValue, C customer
from table1, table2
where table1.A = table2.E
AND C in (Select C from table4 where G=20)
group by C
order by total, minValue
These queries should be executed according to the selectionParameter set to 0 or 1. The only difference in these queries in one of the where clauses. In the formula workshop "record selection"- I have put an if clause.
if(selectParameter = 0) then (B in (Select B from table3 where F=10)
else C in (Select C from table4 where G=20).
This is not supported, since select statement cannot be used in the formula workshop!!.. And also, I have understood that what ever procedure I have been following is completely wrong, since the where clause written in "record selection" formula workshop applies to OUTER SELECT, but not to inner select, which is not what I want!!.
Please help me to solve this puzzle. I am eagerly waiting for a solution.
Thanks and Regards,
Janakiram Dandibhotla.A command object is really the only way to create a custom SQL query in Crystal Reports. You have the option to create a command object after you connect to your datasource.
Alternatively you can create a JavaBean class, create the custom query in the java page, retrieve the resultset, and use that in the report. -
Where clause with inner select ...
I want to create a view similar to the following:
CREATE VIEW VXRAY AS
(SELECT a.modex, b.action_date
FROM itac a, xray b
WHERE a.item_id = b.item_id
AND b.action_date =
(SELECT max(c.action_date)
FROM xray c
WHERE c.item_id = b.item_id
AND To_Char(c.action_date,'yymmdd') <= '980825'));
Unfortunately, I cannot hardcode the date value as shown in the above example.
So my question really is: "How can I construct the view without using a harcoded value ('980825' in above example)?".
Since this view will be accessed by a reporting tool (Safari Reports), there will be no intelligence in the actual SQL query statement other than for example:
"select * from vxray where item_id = 'IID001' and action_date <= '25 Aug 1998' "
I've had some suggestions about using a "GROUP BY" function. (this doesn't work for me since the above example is just a very simplified version of what I'm selecting)
I've also had suggestions about using the "&" paremeter prompt in the inner select (for the date value). Again, won't work (as mentioned earlier with the view being accessed from a Reporting Tool).
If I had the following data in the 2 tables:
================ ==========================
ITAC XRAY
================ ==========================
ITEM_ID MODEX ITEM_ID ACTION_DATE
IID001 1535 IID001 10-DEC-97
IID001 24-AUG-98
IID001 05-OCT-98
SELECT * FROM vxray WHERE item_id = 'IID001' AND to_char(action_date,'yymmdd) <= '980825';
MODEX ACTION_DATE
1535 24 Aug 98Warren, thanx for the prompt reply ... unfortunately that won't work since the problem is not really accessing the view, but the SQL construction of the view itself.
Here's what the real query looks like:
CREATE VIEW vaaarpt AS (
SELECT DISTINCT
a.modex MODEX ,
b.buno BEREAU_NUMBER ,
b.action_date LATEST_ACTION_DATE,
b.status_code STATUS_CODE ,
b.model MODEL ,
c.activity_code ACTIVITY_CODE ,
c.curr_count CURR_COUNT ,
d.item_id ITEM_ID ,
d.sc SC ,
(SELECT Sum(f.new_count)
FROM vusage f
WHERE f.interval_type = c.interval_type
AND f.item_id = c.item_id
AND f.end_datetime > b.action_date) FH_USAGE
FROM itac a, xray b, act1 c, item d
WHERE a.item_id = b.item_id
AND b.item_id = c.item_id
AND c.item_id = d.item_id
AND b.action_date =
(SELECT max (f.action_date)
FROM xray f
WHERE f.item_id = b.item_id
AND To_Char(f.action_date,'yyyy/mm/dd') <= 'xxx') );
Above view construction is incorrect since I don't have the value of xxx at the time when I defined the view. -
How to select rows in the inner JTable rendered in an outer JTable cell
I have wrriten the following code for creating cell specific renderer - JTable rendered in a cell of a JTable.
table=new JTable(data,columnNames)
public TableCellRenderer getCellRenderer(int row, int column)
if ((row == 0) && (column == 0))
return new ColorRenderer();
else if((row == 1) && (column == 0))
return new ColorRenderer1();
else
return super.getCellRenderer(row, column);
ColorRenderer and ColorRenderer1 are two inner classes, which implement TableCellRenderer to draw inner JTable on the outer JTable cell, having 2 rows and 1 column each.
Now what is happening the above code keeps executing continously, that is the classes are being initialised continously, inner JTables are rendered (drawn) continously, and this makes the application slow after some time. It throws java.lang.OutOfMemoryException.
WHY IS IT SO??? I can't understand where's the bug..
Any advice please???
Moreover i want selections in inner tables and not on outer table, how can this be possible.
I am working on this since a long time but have not yet found a way out...With your help i have overcome the problem of continous repeatition.
The major problem which I am facing is, in selecting rows in the inner rendered JTables.
I have added listener on outer JTable which select rows on the outer JTable, hence the complete inner JTable which being treated as a row, gets selected.
The thing is i need to select the rows of inner rendered JTables,not the outer JTable.
How to go about it??
I have even added listener to inner rendered JTables, but only first row of every table gets selected.
Please help....
Thanks in advance. -
Why does SQL execute inner selected functions again in the outer select?
Hi,
Why does SQL execute inner selected functions again in the outer select?
Given:
CREATE OR REPLACE FUNCTION K_TEST
RETURN NUMBER IS
BEGIN
RETURN 1;
END;
SELECT K_TEST, K_TEST FROM DUAL;Will (logically) execute the function twice.
SELECT intest, intest
FROM (SELECT K_TEST intest FROM DUAL);Will execute the function twice too!
Why can't SQL buffer the inner result?
Does anyone have an idea on how to achieve executing the function only once? My original called function is quite heavy and returning a user defined type. Adding predicates, the function is executed 3 or 4 times!
Thanks for any tips,
K.Hello
Depending on your version of Oracle, Sub query caching could help....
XXXX> create sequence seq_1
2 /
Sequence created.
Elapsed: 00:00:00.07
XXXX> CREATE OR REPLACE FUNCTION K_TEST
2 RETURN NUMBER IS
3
4 ln_Ret NUMBER;
5
6 BEGIN
7 SELECT
8 seq_1.NEXTVAL
9 INTO
10 ln_Ret
11 FROM
12 dual;
13
14 RETURN ln_Ret;
15 END;
16 /
Function created.
Elapsed: 00:00:00.60
XXXX>
XXXX> SELECT K_TEST, K_TEST FROM DUAL;
K_TEST K_TEST
1 2
1 row selected.
Elapsed: 00:00:00.06
XXXX> SELECT K_TEST, K_TEST FROM DUAL;
K_TEST K_TEST
3 4
1 row selected.
Elapsed: 00:00:00.01
XXXX> SELECT intest, intest
2 FROM (SELECT K_TEST intest FROM DUAL);
INTEST INTEST
5 6
1 row selected.
Elapsed: 00:00:00.10
XXXX> SELECT
2 intest,intest
3 FROM
4 (
5 SELECT (SELECT K_TEST FROM dual) intest
6 FROM
7 dual
8
9 )
10 /
INTEST INTEST
7 7
1 row selected.
Elapsed: 00:00:00.03
XXXX> /
INTEST INTEST
8 8
1 row selected.
Elapsed: 00:00:00.01THis last example takes advantage of a specific optimisation for calling functions in a subquery. Not sure if it would suit your circumstance though...
Alternatively - again depending on your version - you might be able to look at function result caching...
HTH
David
Edited by: Bravid on Feb 1, 2012 12:32 PM -
HELP ! why doesn't color picker select specific color ? i make secondary layer and use the tool but no colors are selected and the gray out menu shows nothing !
what am i missing ??!!Please add you system info and SpeedGrade version and build number if you actually want help.
-
Using Paint Bucket Fill in Selection puts a 1px line down each side...
I want to fill a selection. I have a simple rectangle path. I make the path a selection and fill it with the paint bucket. I get a line on the left outside the selection:
Then I get a line on the right inside the selection:
There's no line at the top and the bottom of the fill is at the bottom of the image.
This line is only 1px but it's for a web graphic and I am trying to get a pixel-perfect size.
Can anyone tell me why the behaviour and how to avoid it?
Thanks
MartinRefine Edges box did it for me!
I didn't even know about that. When I had a look it was set to 0% contrast and pushing that up to 100% sorted out the probem for me.
Thank you very much.
Martin
Next on my list is to learn about Shape Layers and Fill Pixels. Does this never end? -
How to fill a selection in Layer A with Layer B
Hi,
I've been using Photoshop on a hobby basis for 8 years and I have never figured out to accomplish what seems like this insanely simple task. How do I fill a selection in layer A with the contents of layer B?
To illustrate, right now I am trying to take a visor on a helmet and give it a broken glass effect. The image of the broken glass is suitable to be placed directly into the visor area of the helmet. I select the visor of the helmet with quick selection tool, and all I really need to do is use this selection to "cut out" an area of the same size and shape from my broken glass image and place it on top. However, I have no idea how to do this.
What would be the best practice in this situation?
Thanks,
bodazxOne way to do this is to use the place command under the file menu to insert your broken glass image into your helmet image. Then you can position and size the broken glass image where you want it. Aftet than you can make your selection and use it to create a layer mask for the broken glass image.
-
Selective, non contigiuos fill
I need to change a color in an illustration from one color to another. I need to do it for just a portion of the image. In photoshop, I'd place a selection (e.g. with lasso tool) around the area to be changed, then use the paintbucket tool, select the range of similar colors, and uncheck contigious. Then when I fill the one "spot" all spots in the selection are also filled withthe new color.
Can someone tell me how to do the same in AI(CS)? I've tried and can't manage to do it.
Thanks,
ScottThere are various ways to do this in AI
1. Select the direct selection tool (white arrow) and then select one object, next go to the menu select/same fill color
2. I cant' remember if CS has the magic wand tool on the tool box, this does the same as in point 1, but chek it out.
New version of AI came with more tools to do this here
http://forums.adobe.com/thread/470678?tstart=210 -
Oracle 11g SUM function on the result of inner Select
The inner Select returns rows with the values. The outer select running on tthe result of inner select SUM the result of the inner select.
Although there are valid rows of the inner select the SUM in the outer SELECT return NVL. As a comment any aggregate function on the outer select returns NVL.
The query is below.
select a.yil,
a.ay,
sum(brut_prim),
sum(kom),
from (SELECT oid_pol_kesilen_acente,
to_char(pp.zeyil_tanzim_tar, 'yyyy') yil,
to_char(pp.zeyil_tanzim_tar, 'mm') ay,
sum(decode(substr(pp.no, 1, 1),
'T',
pp.zeyil_brut_prim_fark / 2,
pp.zeyil_brut_prim_fark)) -
sum(pp.zeyil_gv_fark) brut_prim,
sum(pp.zeyil_acente_kom_fark) kom
from pol_police pp, org_acente oa
WHERE SUBSTR(PP.NO, 1, 1) != 'D')
group by oid_pol_kesilen_acente,
to_char(pp.zeyil_tanzim_tar, 'yyyy'),
to_char(pp.zeyil_tanzim_tar, 'mm')) a
group by a.yil, a.ay, oid_pol_kesilen_acente
Edited by: [email protected] on May 7, 2010 2:09 AM
Edited by: [email protected] on May 7, 2010 2:31 AMHi,
please try the below sql:
select a.yil, a.ay, sum(brut_prim), sum(kom),
from (SELECT oid_pol_kesilen_acente,to_char(pp.zeyil_tanzim_tar, 'yyyy') yil, to_char(pp.zeyil_tanzim_tar, 'mm') ay,
sum(decode(substr(pp.no, 1, 1), 'T',nvl(pp.zeyil_brut_prim_fark,0) / 2,nvl(pp.zeyil_brut_prim_fark,0))) - sum(nvl(pp.zeyil_gv_fark,0)) brut_prim,
sum(nvl(pp.zeyil_acente_kom_fark,0)) kom
from pol_police pp, org_acente oa
WHERE SUBSTR(PP.NO, 1, 1) != 'D'
group by oid_pol_kesilen_acente,
to_char(pp.zeyil_tanzim_tar, 'yyyy'),
to_char(pp.zeyil_tanzim_tar, 'mm')
) a
group by a.yil, a.ay, oid_pol_kesilen_acente ;
Thanks,
Siva -
I have a 64GB iPad2 and selected to "Automatically fill free space with songs".... will it have to download that 60GB of music to my ipad everytime I sync? It took about 8 hours to sync the music to it.
I did this last night at 10pm thinking it would take 30 minutes to sync these 10,000 songs or so to my ipad to take up the 64 GB. I went to bed because it was taking so long and woke up at 6am and it was just about to finish. It finished around 630am. So it took a good 8 hours to sync.
I unhooked it and used it for an hour or so and then hooked it backup so that I could update a few apps on it. When i did that it acted like it was re-adding all of those songs again and it took about 8 hours again to sync all the music. Was that just a fluke because I made changes to the ipad? or will it always calculate and then re-sync alllllllllllllllllll of those 10,000 songs?
Thanks so much for any help!!!
-MichaelAnyone?
-
How to use OracleParameter whith the IN Operator of select statement
Hi,
I am having problems using the OracleParameter when used in a query with a IN operator.
Following Example:
oraCommand.Parameters.Add(":List", strMylist ); //or Array???
The SQL command:
SELECT * FROM XXX WHERE XXX.YYY IN (:List);
What datatype must the value of :List be?
regards
StefanLet's use a collection of User Defined Types (UDT's).
First create a table with 1 million rows:
create table employees (id number(10) not null primary key, name varchar2(100) );
insert into employees
select level l, 'MyName'||to_char(level)
from dual connect by level <= 1e6;
1000000 rows created
commit;
exec dbms_stats.gather_schema_stats(USER, cascade=>TRUE);No we turn to the C# code:
Let's select employees with id's 3 and 4.
Collection type MDSYS.SDO_ELEM_INFO_ARRAY is used because if we use this already predefined Oracle type we don't have to define our own Oracle type. You can fill collection MDSYS.SDO_ELEM_INFO_ARRAY with max 1048576 numbers.
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
[OracleCustomTypeMappingAttribute("MDSYS.SDO_ELEM_INFO_ARRAY")]
public class NumberArrayFactory : IOracleArrayTypeFactory
public Array CreateArray(int numElems)
return new Decimal[numElems];
public Array CreateStatusArray(int numElems)
return null;
private void Test()
OracleConnectionStringBuilder b = new OracleConnectionStringBuilder();
b.UserID = "sna";
b.Password = "sna";
b.DataSource = "ora11";
using (OracleConnection conn = new OracleConnection(b.ToString()))
conn.Open();
using (OracleCommand comm = conn.CreateCommand())
comm.CommandText =
@" select /*+ cardinality(tab 10) */ * " +
@" from employees, table(:1) tab " +
@" where employees.id = tab.column_value";
OracleParameter p = new OracleParameter();
p.OracleDbType = OracleDbType.Array;
p.Direction = ParameterDirection.Input;
p.UdtTypeName = "MDSYS.SDO_ELEM_INFO_ARRAY";
p.Value = new Decimal[] { 3, 4 };
comm.Parameters.Add(p);
int numPersons = 0;
using (OracleDataReader reader = comm.ExecuteReader())
while (reader.Read())
MessageBox.Show("Name " + reader[1].ToString());
numPersons++;
conn.Close();
}The index on employees.id isn't used when one omits hint /*+ cardinality(tab 10) */. This index is created by Oracle because id is the primary key column.
Edited by: wateenmooiedag on Dec 30, 2009 2:45 AM -
Problem Filling and Selecting with Paths.jsx
I have copied Paths.jsx from the Adobe Photoshop CS5 Javascript Scripting Reference, p. 141. It works OK. It makes a path that is the outline of an ice cream cone and strokes it with the current foreground color.
I then tried to fill the path and that does not work. I have tried 3 methods using the following additional code and changing the appropriate false's to true:
// Fill the path
fillColor = new SolidColor
fillColor.rgb.red = 255
fillColor.rgb.green = 0
fillColor.rgb.blue = 0
try {
if(false) {
// This works and gives a gray fill that is neither the
// foreground nor background color
// Only the ice cream part of the cone is selected and filled
myPathItem.fillPath()
} else if(false) {
// With a color specified, it doesn't work
myPathItem.fillPath(fillColor)
} else if(true) {
// This makes a selection of the PathItem, selects it and fills it
// Only the ice cream part of the cone is selected and filled
myPathItem.makeSelection(0, false, SelectionType.REPLACE)
selRef = app.activeDocument.selection;
selRef.fill(fillColor, ColorBlendMode.NORMAL)
} catch(ex) {
msg = "Error filling path:\n" + ex.message
alert(msg, "Exception", true);
They do as the comments say. None of them does what I would expect. For the second way, the error message is:
General Photoshop error occurred. This functionality may not be available in this version of Photoshop
- Could not complete the command because of a program error.
I do not understand why only the ice cream part of the cone is filled or selected (the third array). I can manually make a selection from the Path in PS and it also only selects the ice cream part. All of the lines are stroked. Only the top part is filled or selected.
Why does fillPath not work?
I can supply the whole script if necessary. I am an experienced programmer but new to Photoshop scripting. Is this a bug or am I doing something wrong?
Thanks for any help.This is the whole script:
// Paths.jsx
#target photoshop
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits
var startTypeUnits = app.preferences.typeUnits
var startDisplayDialogs = app.displayDialogs
// Set Adobe Photoshop CS5 to use pixels and display no dialogs
app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.displayDialogs = DialogModes.NO
// First close all the open documents
while (app.documents.length) {
app.activeDocument.close()
// Create a document to work with
var docRef = app.documents.add(5000, 7000, 72, "Simple Line")
// line 1--it’s a straight line so the coordinates for anchor, left, and right
// for each point have the same coordinates
var lineArray = new Array()
lineArray[0] = new PathPointInfo
lineArray[0].kind = PointKind.CORNERPOINT
lineArray[0].anchor = Array(100, 100)
lineArray[0].leftDirection = lineArray[0].anchor
lineArray[0].rightDirection = lineArray[0].anchor
lineArray[1] = new PathPointInfo
lineArray[1].kind = PointKind.CORNERPOINT
lineArray[1].anchor = Array(150, 200)
lineArray[1].leftDirection = lineArray[1].anchor
lineArray[1].rightDirection = lineArray[1].anchor
var lineSubPathArray = new Array()
lineSubPathArray[0] = new SubPathInfo()
lineSubPathArray[0].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[0].closed = false
lineSubPathArray[0].entireSubPath = lineArray
// line 2
var lineArray2 = new Array()
lineArray2[0] = new PathPointInfo
lineArray2[0].kind = PointKind.CORNERPOINT
lineArray2[0].anchor = Array(150, 200)
lineArray2[0].leftDirection = lineArray2[0].anchor
lineArray2[0].rightDirection = lineArray2[0].anchor
lineArray2[1] = new PathPointInfo
lineArray2[1].kind = PointKind.CORNERPOINT
lineArray2[1].anchor = Array(200, 100)
lineArray2[1].leftDirection = lineArray2[1].anchor
lineArray2[1].rightDirection = lineArray2[1].anchor
lineSubPathArray[1] = new SubPathInfo()
lineSubPathArray[1].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[1].closed = false
lineSubPathArray[1].entireSubPath = lineArray2
// Ice cream curve
// It’s a curved line, so there are 3 points, not 2
// coordinates for the middle point (lineArray3[1]) are different.
// The left direction is positioned "above" the anchor on the screen.
// The right direction is positioned "below" the anchor
// You can change the coordinates for these points to see
// how the curve works...
var lineArray3 = new Array()
lineArray3[0] = new PathPointInfo
lineArray3[0].kind = PointKind.CORNERPOINT
lineArray3[0].anchor = Array(200, 100)
lineArray3[0].leftDirection = lineArray3[0].anchor
lineArray3[0].rightDirection = lineArray3[0].anchor
lineArray3[1] = new PathPointInfo
lineArray3[1].kind = PointKind.CORNERPOINT
lineArray3[1].anchor = Array(150, 50)
lineArray3[1].leftDirection = Array(100, 50)
lineArray3[1].rightDirection = Array(200, 50)
lineArray3[2] = new PathPointInfo
lineArray3[2].kind = PointKind.CORNERPOINT
lineArray3[2].anchor = Array(100, 100)
lineArray3[2].leftDirection = lineArray3[2].anchor
lineArray3[2].rightDirection = lineArray3[2].anchor
lineSubPathArray[2] = new SubPathInfo()
lineSubPathArray[2].operation = ShapeOperation.SHAPEXOR
lineSubPathArray[2].closed = false
lineSubPathArray[2].entireSubPath = lineArray3
// Create the path item
var myPathItem = docRef.pathItems.add("A Line", lineSubPathArray)
// Stroke it so we can see something
myPathItem.strokePath(ToolType.BRUSH)
// Fill the path
fillColor = new SolidColor
fillColor.rgb.red = 255
fillColor.rgb.green = 0
fillColor.rgb.blue = 0
try {
if(false) {
// This works and gives a gray fill that is neither the
// foreground nor background color
// Only the ice cream part of the cone is selected and filled
myPathItem.fillPath()
} else if(false) {
// With a color specified, it doesn't work
myPathItem.fillPath(fillColor)
} else if(true) {
// This makes a selection of the PathItem, selects it and fills it
// Only the ice cream part of the cone is selected and filled
myPathItem.makeSelection(0, false, SelectionType.REPLACE)
selRef = app.activeDocument.selection;
selRef.fill(fillColor, ColorBlendMode.NORMAL)
} catch(ex) {
msg = "Error filling path:\n" + ex.message
alert(msg, "Exception", true);
// Reset the application preferences
preferences.rulerUnits = startRulerUnits
preferences.typeUnits = startTypeUnits
displayDialogs = startDisplayDialogs
Maybe you are looking for
-
How do I apply a Mail rule to only a certain mailbox?
I want to put certain messages into a mailbox and have them "expire" (be deleted) in 30 days. For example, I want to put all my "email receipts" in a folder after I complete the transaction and have Mail automatically delete them after 30 days. That
-
We have a project in our Project Server 2010 environment and it was being managed for a period of time without any issues. Recently, a user has gone into PWA and edited the schedule in PWA by deleting all the tasks and re-creating a new set of tasks
-
I've started first workflow. I would like to automate the process of cleaning out my email periodically from my ISP. There is a web based method. The workflow works fine until I get to the page where I have to enter my user name in one field and pass
-
Hi Group, Confifuring webservice->file asynchronous scenario ,in this scenario PI providing the webservice with request and response,once after file request is triggered needs to send back response as OK,can any body suggest how we can configure.
-
i need some sample code and help on " On change of " pls help me