## AutoCAD Plant 3D General DIscussion

Valued Contributor
Posts: 51
Registered: ‎06-20-2011
Message 1 of 4 (299 Views)

# plant report creator

299 Views, 3 Replies
02-11-2013 01:00 AM

hello

is it possible to had 20% on subtotale for part

for exemple when the report say you have 10 elbow 90°.. i need in an other columns it say 12 elbow 90°...

because the report is the exact numbur of part but when we ship material we need more parts...

i don't know if it's clear..

thank you

*Expert Elite*
Posts: 658
Registered: ‎12-04-2009
Message 2 of 4 (291 Views)

# Re: plant report creator

02-11-2013 06:45 AM in reply to: patpat78

Yes, you could do it using scripts. Look at the default 3d parts BOM and open the scripts section.  There is a function they use to get the total that will be used.  You can replace the two function below (feetInchesFromObject and tableCell4_SummaryCalculated) with the code below.

I've modified the function to return 120% of the items, and made it so any fractional value round up to 1", this part just affects the piping.

// Return the specified object as a double value formatted
// into feet and inches.
//
private string
feetInchesFromObject(object obj)
{

UsedFeetandInches = true;
System.Diagnostics.Debug.Assert(
obj != null,
/*NOXLATE*/"feetInchesFromObject: obj parameter is null");
if (obj == null)
return string.Empty;

double value = System.Convert.ToDouble(obj);
//add fudge factor to the double
value = 1.2 * value;
// Round the initial value to three decimal places
// to avoid borderline rounding cases than would
// have resulted in very small or very large fractional
// inches.
double inchesFull = System.Math.Round(value % 12, 3);
double inchesOnly = System.Math.Truncate(inchesFull);

//round up the inches if there are any fractional left overs from our fudge factor
if(inchesFull - inchesOnly > 0)
inchesOnly++;
// Compute the fractional inches, if any.
string fracText = string.Empty;
double frac = inchesFull - inchesOnly;

//make sure there are no fractional values

frac =0;
if (frac > 0.0) {
fracText = string.Format(
/*NOXLATE*/" 1/{0}",
System.Math.Round(1 / frac)
);
}

// We always include the feet and inches.
// The fractional inches are optional.
return string.Format(
/*NOXLATE*/"{0}'-{1}{2}\"",
System.Math.Truncate(value / 12),
System.Convert.ToString(inchesOnly),
fracText
);
}

private void
tableCell4_SummaryCalculated(
object sender,
DevExpress.XtraReports.UI.TextFormatEventArgs e)
{
UsedFeetandInches = false;
textFeetInchesIfColumnImperial(/*NOXLATE*/"MeasureUnit", e);
//don't do anything if we already calculated the feet and inches
if(UsedFeetandInches)
return;
//get the value
double sum = System.Convert.ToDouble(e.Text);
//add our fudge factor, and round up to the nearest integer ie 2.1 goes up to 3;
e.Text = Math.Ceiling(sum * 1.2).ToString();

}
bool UsedFeetandInches;

Dave Wolfe
Isaiah 57:15

Tips and Tricks on our blog: Process Design, from the Outside

A P3D Authorized Reseller
Valued Contributor
Posts: 51
Registered: ‎06-20-2011
Message 3 of 4 (262 Views)

# Re: plant report creator

02-13-2013 08:19 AM in reply to: dave.wolfe

hello

i copy paste the script but it say erraor on line 57 any idea ?

*Expert Elite*
Posts: 658
Registered: ‎12-04-2009
Message 4 of 4 (254 Views)

# Re: plant report creator

02-13-2013 08:31 AM in reply to: patpat78

Try substituting this in the summary calculated section

where it says:

//get the value
double sum = System.Convert.ToDouble(e.Text);
//add our fudge factor, and round up to the nearest integer ie 2.1 goes up to 3;
e.Text = Math.Ceiling(sum * 1.2).ToString();

use this:

//get the value

double sum = 0.0;

try{

sum = System.Convert.ToDouble(e.Text);//add our fudge factor, and round up to the nearest integer ie 2.1 goes up to 3;
e.Text = Math.Ceiling(sum * 1.2).ToString();

catch{

//do nothing if we couldn't convert to a double

}

Dave Wolfe
Isaiah 57:15

Tips and Tricks on our blog: Process Design, from the Outside

A P3D Authorized Reseller

### You are not logged in.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.