AutoCAD Plant 3D Forum
Welcome to Autodesk’s AutoCAD Plant 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Plant 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Plant Report - Pipe in Feet & Inches

23 REPLIES 23
SOLVED
Reply
Message 1 of 24
JoeKay
2929 Views, 23 Replies

Plant Report - Pipe in Feet & Inches

How can I get the quanties to show up in feet and inches for pipe? Right now it defaults to IN which for pipe does nothing for me. I'm sure its a scripting thing but I didnt think I had to take programming classes to edit basic functions in the program. If you have an answer can you step by step the instructions so I can understand it better. I have found some answers but no step by step instructions to apply them. Just 'add it to the script'. I'm using a modification on the default 3D Parts report, if that helps. Thanks
23 REPLIES 23
Message 2 of 24
jabowabo
in reply to: JoeKay

The default reports all (I think) have a function for converting.  All you need to do is make sure your quantity cell calls the function in the scripting area.  

1. Find the cell name (tableCell4 in this pic):

Capture.PNG

 

2.  In the Scripts section, change the original cell function to your cell name (just change 'tableCell4' as shown below) or Copy/Paste the function and change the cell name to yours:

Capture2.PNG 

Message 3 of 24
JoeKay
in reply to: jabowabo

Thanks for the reply but that did not help. I see the table cell, I see the script part in the properties, I can click on it to were the script shows. But I dont get what your telling me to do after that. Sorry.
Message 4 of 24
jabowabo
in reply to: JoeKay

There is a "Scripts" button on the ribbon that will open the scripting module. You should see a bit of code almost exactly as circled in my 2nd pic. All you need to do is change the cell name in the code to match yours.
Message 5 of 24
JoeKay
in reply to: jabowabo

Thanks again for the reply. I got it to work now. I was confused cause I had that same script as you circled with the appropriate cell number. It took me switching it to another cell number then back again to get it to work. But it its all good now. Thanks again.
Message 6 of 24
JoeKay
in reply to: JoeKay

New problem. When I do the preview in the report creator it shows my pipe in feet and inches. When I go to export it, it changes back to inches? WHY?! This program over complicates things.
Message 7 of 24
jabowabo
in reply to: JoeKay

Excel is changing it.  When you export select the 'Text' option.

2014-01-07_160123.png

Message 8 of 24
JoeKay
in reply to: jabowabo

Thank you again! I owe you a coke.
Message 9 of 24
andrew.hopen
in reply to: JoeKay

So i have tried this sveral times in plant report 2017 and cannot get it to work.  Has somthing changed since 2014?

Message 10 of 24
andrew.hopen
in reply to: jabowabo

So i have tried this sveral times in plant report 2017 and cannot get it to work.  Has somthing changed since 2014?

Message 11 of 24
jabowabo
in reply to: andrew.hopen

I'm still on 2016 so I don't know if it works on newer versions.

Message 12 of 24
andrew.hopen
in reply to: jabowabo

So here are a couple of screen shots. Maybe it will help pin point if I am doing something wrong.

Message 13 of 24
jabowabo
in reply to: andrew.hopen

Your event handler method (tableCell5_SummeryCalculated) is misspelled. This may or may not be a problem depending on how the event is called. The bigger problem though is that it is calling a method that does not exist in the code you show in your screenshot (TextFeetInchesIfColumnImperial). You need to add the TextFeetInchesIfColumnImperial method - you can probably find it in one of the OOTB reports and paste it in.
Message 14 of 24
andrew.hopen
in reply to: jabowabo

Thanks for the catch.  So i am new to scripting.  What are the OOTB reports and where would I find them? Thanks for the help

Message 15 of 24
andrew.hopen
in reply to: jabowabo

Thanks for the catch.  So I am new to scripting.  What are the OOTB reports and where would I find them? Thanks for the help

Message 16 of 24
andrew.hopen
in reply to: jabowabo

Thanks for the catch. So I am new to scripting.  What are the OOTB reports and where would I find them? Thanks for the help

Message 17 of 24
jabowabo
in reply to: andrew.hopen

Out of the box - these are the default reports that the software comes with - although I did not see the missing code in the few I checked. Here's the full code from one of my old reports (I only report decimal feet now so it can be calculated in Excel). You will need to modify to suit your report layout. Make sure the 'SummaryCalculated' event of your length cell points to the method 'tableCell5_SummaryCalculated'.

 

 

// Return the specified object as a double value formatted
// into feet and inches.
//
private string
feetInchesFromObject(object obj)
{
    System.Diagnostics.Debug.Assert(
        obj != null,
        /*NOXLATE*/"feetInchesFromObject: obj parameter is null");
    if (obj == null)
        return string.Empty;

    double value = System.Convert.ToDouble(obj);

    // 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);

    // Compute the fractional inches, if any.
    string fracText = string.Empty;
    double frac = inchesFull - inchesOnly;
    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
tableCell5_SummaryCalculated(
    object sender,
    DevExpress.XtraReports.UI.TextFormatEventArgs e)
{
    textFeetInchesIfColumnImperial(/*NOXLATE*/"MeasureUnit", e);
}

// Convert TextFormatEventArgs.Text to feet and inches
// if the specific column value indicates imperial
// units.
private void
textFeetInchesIfColumnImperial(
    string unitColumnName,
    DevExpress.XtraReports.UI.TextFormatEventArgs e)
{
    // Validate unitColumnName parameter.
    System.Diagnostics.Debug.Assert(unitColumnName != null,
        /*NOXLATE*/"textFeetInchesIfColumnImperial: unitColumnName is null");
    if (unitColumnName == null)
        return;

    // Validate TextFormatEventArgs parameter.
    System.Diagnostics.Debug.Assert(
        e != null,
        /*NOXLATE*/"textFeetInchesIfColumnImperial: TextFormatEventArgs parameter is null");
    if (e == null)
        return;
    if (e.Value == null) {
        // We have no value, so do nothing.
        return;
    }

    string mu = GetCurrentColumnValue(unitColumnName) as string;
    if (mu == null) {
        // We cannot determine the unit, so do nothing.
        return;
    }
    if (mu.Trim().ToUpperInvariant() == /*NOXLATE*/"IN")
        e.Text = feetInchesFromObject(e.Value);
}

 

NOTE: I probably owe some/all credit for this code to someone but I can't remember where I stole it from 😉

Message 18 of 24
andrew.hopen
in reply to: jabowabo

Okay I created a new template from existing OOTB templates.  3D parts to be specific. I am still getting the same error.

Message 19 of 24
andrew.hopen
in reply to: andrew.hopen

Didn’t see your previous post.  Will try it now.

Message 20 of 24
andrew.hopen
in reply to: jabowabo

Okay that worked and everything was validated. My test report comes out tableCell5 as still in decimal inches?  Again thanks for your help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost