AutoCAD Civil 3D Customization

Reply
*Expert Elite*
Civil3DReminders.com
Posts: 2,437
Registered: ‎10-13-2005
Message 1 of 8 (271 Views)

Profile View Bands

271 Views, 7 Replies
01-11-2014 06:06 PM

I'm having difficulty adding bands to a profile view in Civil 3D 2013 in that the bands appear to be come corrupt in not showing the data (the check box to show is unselected, even if I set it to show) and when I go into the UI and turn the bands to show the bands don't show the information correctly. 

 

                Alignment align = profileView.AlignmentId.GetObject(OpenMode.ForRead) as Alignment;
                Profile prof = profObjId.GetObject(OpenMode.ForRead) as Profile;

                if (!profileView.IsWriteEnabled)
                    profileView.UpgradeOpen();

                profileView.StyleId = profViewStyleObjId;

                ProfileViewBandItemCollection bottomBandItems = profileView.Bands.GetBottomBandItems();
                ProfileViewBandItemCollection topBandItems = profileView.Bands.GetTopBandItems();

                bottomBandItems.RemoveAll();
                topBandItems.RemoveAll();

                profileView.Bands.ImportBandSetStyle(profileBandSetId);
                bottomBandItems = profileView.Bands.GetBottomBandItems();
                topBandItems = profileView.Bands.GetTopBandItems();

                profileView.Bands.SetBottomBandItems(bottomBandItems);
                profileView.Bands.SetTopBandItems(topBandItems);

 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 2 of 8 (253 Views)

Re: Profile View Bands

01-12-2014 09:28 AM in reply to: Civil3DReminders.com

Hi,

 

This should have worked.

Are you trying this code snippet inside a Transaction? and Are you committing the Transaction ?

 

Thanks,

 

 



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

*Expert Elite*
Civil3DReminders.com
Posts: 2,437
Registered: ‎10-13-2005
Message 3 of 8 (245 Views)

Re: Profile View Bands

01-12-2014 04:26 PM in reply to: Partha.Sarkar

Here is some complete code that you can try.

 

        [CommandMethod("TestBands")]
        public void TestBandsIn2013()
        {
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                // Select the Profile View
                var promptResultsPV = ed.GetEntity("Select Profile View");
                var promptResultProfile = ed.GetEntity("Select Profile: ");
                // Add the profile to the profile view.
                ProfileView testPV = promptResultsPV.ObjectId.GetObject(OpenMode.ForWrite) as ProfileView;

                ProfileViewBandItemCollection bottomBandItems = testPV.Bands.GetBottomBandItems();
                ProfileViewBandItemCollection topBandItems = testPV.Bands.GetTopBandItems();

                bottomBandItems.RemoveAll();
                topBandItems.RemoveAll();

                var civDoc = CivilApplication.ActiveDocument;

                testPV.Bands.ImportBandSetStyle(civDoc.Styles.ProfileViewBandSetStyles[0]);
                bottomBandItems = testPV.Bands.GetBottomBandItems();
                topBandItems = testPV.Bands.GetTopBandItems();

                foreach (ProfileViewBandItem bandItem in bottomBandItems)
                {
                    switch (bandItem.BandType)
                    {
                        case Autodesk.Civil.BandType.HorizontalGeometry:
                            bandItem.Profile1Id = promptResultProfile.ObjectId;
                            break;
                        case Autodesk.Civil.BandType.PipeNetwork:
                            //if (PipeNetworkObjId != ObjectId.Null)
                            //{
                            //    bandItem.DataSourceId = PipeNetworkObjId;
                            //}
                            break;
                        case Autodesk.Civil.BandType.ProfileData:
                            bandItem.Profile1Id = promptResultProfile.ObjectId;
                            break;
                        case Autodesk.Civil.BandType.SectionData:
                            break;
                        case Autodesk.Civil.BandType.SectionSegment:
                            break;
                        case Autodesk.Civil.BandType.SectionalData:
                            break;
                        case Autodesk.Civil.BandType.SuperelevationData:
                            break;
                        case Autodesk.Civil.BandType.VerticalGeometry:
                            bandItem.Profile1Id = promptResultProfile.ObjectId;
                            break;
                        default:
                            break;
                    }
                }

                testPV.Bands.SetBottomBandItems(bottomBandItems);
                testPV.Bands.SetTopBandItems(topBandItems);
                
                //testPV.AddProfileToBand(promptResultProfile.ObjectId, invertHelper.ProfileViewBandNames,
                //                                       invertHelper.ProfViewBandSetStyle.ObjId, PipeNetworkObjId, invertHelper.ProfileViewStyle.ObjId);


                trans.Commit();
            }
        }

 Attached is a drawing that you can run the code on. Select the profile view and then the profile. The band is updated with the bandset, but the bands are set to not show up. I find that I get different results when the band set only has one band in it (it shows it correctly), but having more then one band appears to lead to the issues.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
*Expert Elite*
Jeff_M
Posts: 4,175
Registered: ‎07-22-2003
Message 4 of 8 (239 Views)

Re: Profile View Bands

01-12-2014 05:23 PM in reply to: Civil3DReminders.com
Other than the pasting of the code mangled it a bit, I'm seeing the incorrect results, too, in 2014.
Jeff_M, also a frequent Swamper
ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 5 of 8 (217 Views)

Re: Profile View Bands

01-15-2014 02:43 AM in reply to: Jeff_M

Hi Chris / Jeff,

 

I tried the following code snippet in Civil 3D 2014 on a Civil 3D sample dwg file ( Profile-6B.dwg).

I removed the Profile view topbands before I run my following C# .NEt code sample. I find the bands are added with proper data. 

Am I missing something here ?

 

My C# .NET code snippet :

 

       

//select a profile view

       

Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;

       

PromptEntityOptions peo = newPromptEntityOptions("\nSelect a profile view: ");

        peo.SetRejectMessage(

"\nSelect only profile views");

        peo.AddAllowedClass(

typeof(ProfileView), true);

       

PromptEntityResult per = ed.GetEntity(peo);

       

if (per.Status != PromptStatus.OK) return;

       

ObjectId pvId = per.ObjectId;

       

Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;

       

using (Transaction trans = db.TransactionManager.StartTransaction())

        {

         

CivilDocument civilDoc = CivilApplication.ActiveDocument;

         

//open the profile view

         

ProfileView pv = trans.GetObject(pvId, OpenMode.ForWrite) asProfileView;

         

//get the style of the first Bottom Bands

         

ObjectId bandStyleId = pv.Bands.GetBottomBandItems()[0].BandStyleId;

         

//now access the collection of top band

         

ProfileViewBandItemCollection topBandItems = pv.Bands.GetTopBandItems();

         

//add a new one (using the above style)

          topBandItems.Add(bandStyleId);

         

//now Set the Top Bands

          pv.Bands.SetTopBandItems(topBandItems);

          trans.Commit();

 

 

Screenshot before I add the Profile View Top band :

 

 Civil_3D_ProfileView_TopBand_Empty.png

 

 

Screenshot after I added the Profile View Top band using the above code snippet :

 

Civil_3D_ProfileView_TopBand_API.png

 

Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

*Expert Elite*
Civil3DReminders.com
Posts: 2,437
Registered: ‎10-13-2005
Message 6 of 8 (205 Views)

Re: Profile View Bands

01-15-2014 08:01 AM in reply to: Partha.Sarkar

Partha,

 

I want to add the entire an entire band set with multiple bands. It works correctly with one band, but add four to the mix and it quickly goes downhill. Also I'm adding an entire band set at once, not one at a time. I'll try adding the bands one at a time, but it seems like the code is going to be slow, especially if I have to add the bands in seperate transactions just so Civil 3D doesn't screw up the bands. I'd prefer not to code around bugs and would like to see the bug fixed.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
*Expert Elite*
Civil3DReminders.com
Posts: 2,437
Registered: ‎10-13-2005
Message 7 of 8 (201 Views)

Re: Profile View Bands

01-15-2014 09:51 AM in reply to: Partha.Sarkar

Partha,

 

This won't really work. After adding the bands I have to go back and set ALL of the settings to match what was in the band set style. This includes weeding, gap, profile locations to label, etc... This is a severe bug for the API to have. I'd prefer Autodesk spend the time fixing the bug then me spending 4 to 8 hours working around it.

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
ADN Support Specialist
Partha.Sarkar
Posts: 543
Registered: ‎06-09-2009
Message 8 of 8 (192 Views)

Re: Profile View Bands

01-15-2014 09:43 PM in reply to: Civil3DReminders.com

Ok, I will investigate this further.

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

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.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Civil 3D Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for AutoCAD Civil 3D helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Civil 3D

Twitter

Facebook

Blogs