Create Profile Views by Alignment

Adding Band Sets to the above code I am getting problems, I have looked through api docs and I am confused as to how to get the id’s for Profile views Band Set styles, I thought maybe it was spacing in names so added underscores , but it appears I am referencing wrong styles!

help appreciated:

import clr

# Add Assemblies for AutoCAD and Civil 3D APIs
clr.AddReference('acmgd')
clr.AddReference('acdbmgd')
clr.AddReference('accoremgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('AeccPressurePipesMgd')
clr.AddReference('acdbmgdbrep')
clr.AddReference('System.Windows.Forms')

# Add standard Python references
import sys

sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')
import os
import math

# Add references to manage arrays, collections and interact with the user
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox

# Create an alias to the Autodesk.AutoCAD.ApplicationServices.Application class
import Autodesk.AutoCAD.ApplicationServices.Application as acapp

# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references for Civil 3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument


def point_to_point3d(pt):
    return Point3d(pt.X, pt.Y, pt.Z)

def create_profile_view(align, loc, vn, style, bandset1, bandset2, bandset3):
    global adoc
    global ed
    global civdoc

    result = []

    # Get the active document in the AutoCAD session:
    with adoc.LockDocument():
        with adoc.Database as db:
            with db.TransactionManager.StartTransaction() as t:
                # get alignment
                alignId = align.InternalObjectId
                # location
                pos = point_to_point3d(loc)
                # bandset
                bandSetId = civdoc.Styles.ProfileViewBandSetStyles[bandset1]
                # bandset1
                botbandSetId1 = civdoc.Styles.ProfileViewBandSetStyles[bandset2]
                # bandset2
                botbandSetId2 = civdoc.Styles.ProfileViewBandSetStyles[bandset3]               
                # style
                styleId = civdoc.Styles.ProfileViewStyles[style]
                for n in vn:
                    try:
                        # Creates a new profile view
                        profId = ProfileView.Create(alignId, pos, n, bandSetId, styleId)
                        botBandItems = profId.Bands.GetBottomBandItems()
                        botBandItems.Add(botbandSetId1)
                        botBandItems.Add(botbandSetId2)
                        profId.Bands.SetBottomBandItems(botBandItems)
                    except Exception() as ex:
                        MessageBox.Show(ex.message)

                t.Commit()
    for n in vn:
        result.append(profId)
    return result


alignment = IN[0]
position = IN[1]
names = IN[2]
StyleName = IN[3]
bandsetName1 = IN[4]
bandsetName2 = IN[5]
bandsetName3 = IN[6]

if not isinstance(names, list):
    names = [names]

create_profile_view(alignment, position, names, StyleName, bandsetName1, bandsetName2, bandsetName3)
1 Like