How to Edit Elevation (Min and Max) in Section View

How to Edit Elevation (Min and Max) in Section View

Anonymous
Not applicable
16,132 Views
35 Replies
Message 1 of 36

How to Edit Elevation (Min and Max) in Section View

Anonymous
Not applicable

Hi,

 

I tried to edit the Elevation Minimum & maximum in the GRAPH_SECTION_VIEW  using following lisp program,

 

but getting a error  " ; error: Invalid number of parameters "

 

(defun c:MMElevation()
(vl-load-com)
(if (setq SelEntobj (ssget "+.:S:E" '((0 . "AECC_GRAPH_SECTION_VIEW"))))
(progn
(setq EntObj (ssname SelEntobj 0))
(setq ObjName(vlax-Ename->Vla-Object EntObj))
(setq ElevationMin (vlax-get ObjName 'ElevationMin))
(setq ElevationMax (vlax-get ObjName 'ElevationMax))
(if (> ElevationMin 0.0)
(progn
(vlax-put ObjName 'ElevationMin 0.0)
(vlax-put ObjName 'ElevationMax (- ElevationMax ElevationMin))
)
)
)
(alert "No Object Selected")
)
(princ)
)

0 Likes
Accepted solutions (1)
16,133 Views
35 Replies
Replies (35)
Message 2 of 36

Jeff_M
Consultant
Consultant

@Anonymous, Welocme to the forums! For future posts with code, use the Code button and paste the code into the window provided. This will prevent the forums from placing smiley faces in the code Smiley Happy

 

The SectionView elevation and offset properties are read only in COM/ActiveX, so cannot be done in lisp. Using the .NET API you are able to set the Automatic/User SPecified toggle for the elevations and offsets, as well as change the values used. I have a similar function I created to set all sectionviews to use the same min/max values, it is written in c# if you are interested in going that route.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 36

Anonymous
Not applicable
Thanks jeff for your information,

Can I get the tool or code.
if code means then I can update as per the requirement and I don't have
much knowledge in c#. And I am a beginner in vb.Net
0 Likes
Message 4 of 36

Jeff_M
Consultant
Consultant
Accepted solution

Attached is a compiled DLL in a zip file. After downloading be sure to go to the ZIP file's properties and Unblock the zip, otherwise the extracted dll won't load. Also providing the c# code, which should be valid for C3D 2013-2016.

 

/// 
/// Created by Jeff Mishler
/// Quux Software LLC
/// http://www.quuxsoft.com
/// 

using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Civil.DatabaseServices;

namespace Civil3D_Misc_Commands.SectionViews
{
    public class SectionViews
    {

        [CommandMethod("SVMinMax")]
        public void svminmax()
        {
            try
            {
                SVMinMaxcommand();
            }
            catch
            {
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("****Uh oh! This command is unable to be used in C3D 2013 or older!****");
            }
            finally
            {
                Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\nThis Utility brought to you by: Quux Software, creators of the Sincpac-C3D.");
            }
        }

        private void SVMinMaxcommand()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            double min = Double.MinValue, max = Double.MaxValue;
            PromptSelectionOptions ssOpts = new PromptSelectionOptions();
            ssOpts.MessageForAdding = "Select SectionViews to adjust Min/Max values:";
            ssOpts.MessageForRemoval = "...Select SectionViews to remove from selection:";
            ssOpts.RejectObjectsOnLockedLayers = true;
            TypedValue[] tv = { new TypedValue(0, "AECC_GRAPH_SECTION_VIEW") };
            SelectionFilter filter = new SelectionFilter(tv);
            PromptSelectionResult ssRes = ed.GetSelection(ssOpts, filter);
            if (ssRes.Status != PromptStatus.OK)
                return;
            PromptDoubleOptions dOpts = new PromptDoubleOptions("\nEnter new Minimum elevation for sectionviews:");
            dOpts.AllowArbitraryInput = false;
            PromptDoubleResult dRes = ed.GetDouble(dOpts);
            if (dRes.Status != PromptStatus.OK)
                return;
            min = dRes.Value;
            dOpts.Message = "\nEnter new Maximum elevation for sectionviews:";
            dOpts.DefaultValue = min + 1;
            dOpts.UseDefaultValue = true;
            dRes = ed.GetDouble(dOpts);

            if (dRes.Status != PromptStatus.OK)
                return;
            max = dRes.Value;
            while (max < min)
            {
                dOpts.Message = "...Max must be higher than Min, try again:";
                dRes = ed.GetDouble(dOpts);

                if (dRes.Status != PromptStatus.OK)
                    return;
                max = dRes.Value;
            }
            using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
            {
                foreach (ObjectId id in ssRes.Value.GetObjectIds())
                {
                    SectionView sv = (SectionView)id.GetObject(OpenMode.ForWrite);
                    if (sv.IsElevationRangeAutomatic)
                        sv.IsElevationRangeAutomatic = false;
                    sv.ElevationMax = max;
                    sv.ElevationMin = min;
                }
                tr.Commit();
            }            
        }
    }
}
Jeff_M, also a frequent Swamper
EESignature
Message 5 of 36

Anonymous
Not applicable

Hi Jeff,

 

Sorry for the late reply, Thanks & Your tools works really great.

0 Likes
Message 6 of 36

Anonymous
Not applicable

Jeff,

Just found your solution.  Svminmax.dll works great on Civil 3D 2014.  Thanks!

Greg

0 Likes
Message 7 of 36

Anonymous
Not applicable

Thank you so much!!!!! WORK IN CIVIL3d 2018 AS WELL

Message 8 of 36

Anonymous
Not applicable

I'm a beginner when it come to dll file. Could please show me how to use this? Thanks

Message 9 of 36

Jeff_M
Consultant
Consultant
Download the ZIP file, Unblock it as described above, save the DLL to a location you know, in C3D us ethe NETLOAD command, browse to the DLL and load it. Then the command SVMINMAX will (should) be available.
Jeff_M, also a frequent Swamper
EESignature
Message 10 of 36

Anonymous
Not applicable

Thanks Jeff! It works wonder!!

0 Likes
Message 11 of 36

Anonymous
Not applicable

Hi, Thanks for the command it is very useful indeed!

 

Another thing though, Can i have a modified version of this that the Maximum Elevation will set at "Minimum + 10", as on our work pattern the Section View Graph is set to 10 unit height, so no need to input the maximum value. Can be set at different command like "SVHt". By this we will input Minimum Elevation only every time we run the command.

 

Thanks a lot in advance!

0 Likes
Message 12 of 36

Jeff_M
Consultant
Consultant

@Anonymous Attached is an updated DLL which includes the new command SVHT. When selecting the SectionViews you can use the SEttings option to set the height above minimum elevation which is saved for future running of the command. The default is 10. 

 

Jeff_M, also a frequent Swamper
EESignature
Message 13 of 36

sbrasher
Enthusiast
Enthusiast

You are my HERO!!! The lack of this kind of tool in C3D has driven me crazy for years and I can't believe how well your dll works!! THANK YOU, THANK YOU, THANK YOU FOR SHARING IT!!!

0 Likes
Message 14 of 36

leon.smolic
Explorer
Explorer

Is there a dll for manipulating Offset also? - it would be greatly appreciated if anyone has one and want to share.

0 Likes
Message 15 of 36

Anonymous
Not applicable

thank you. I use in c3d 2020 

0 Likes
Message 16 of 36

Anonymous
Not applicable
thank you. i use in c3d 2020
0 Likes
Message 17 of 36

Jeew-m
Mentor
Mentor

This saves my day..... Thanks @Jeff_M



Jeewana Meegahage
Design Engineer
Autodesk Civil 3D Tutorials
Facebook | YouTube | LinkedIn







0 Likes
Message 18 of 36

john.uhden
Mentor
Mentor

Hi, @Jeff_M ,

I am still at best stumbling along in learning C3D.

I noticed the 'ElevationMin object property when I dumped a profile view and it didn't say (RO), but vlax-putting the property failed.

Is there another "normal" way to raise the bottom of a profile view?  I have lots of wasted space taken up by nothing but grid lines.

John F. Uhden

0 Likes
Message 19 of 36

Jeff_M
Consultant
Consultant

@john.uhden the 'normal' method is to allow automatic elevations and setting the grid padding in the SectionView Style to a smaller value. To modify the ElevMin/Max values requires 2 things...the IsElevationRangeAutomatic property must be set to false and you must be using the .NET API since the Elev* properties in COM are read only and that needed property isn't even available:

http://docs.autodesk.com/CIV3D/2012/ENU/API_Reference_Guide/com/AeccXLandLib__IAeccSectionView.htm

 

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 20 of 36

john.uhden
Mentor
Mentor
@Jeff_M
Many thanks, Jeff.
Luckily I made another quick profile and the base elevation came out
satisfactory, so the problem has gone away for now.

John F. Uhden

0 Likes