Applied Assembly setting - Creating corridors with python

I’m currently experiencing an issue which is hopefully due to my Python knowledge being pretty basic.

I have developed some Python code which creates corridors from alignments and profiles. This works as expected however, it does not apply the correct frequency and results in horizontal geometry points being skipped like the below image

To get around this issue I have been using BaselineRegion.AppliedAssemblySetting from the API http://help.autodesk.com/view/CIV3D/2020/ENU/?guid=8655c4e7-c02f-26cd-899b-8ea6f86ede24 and attempting to set the AppliedAtHorizontalGeometryPoints property of the AppliedAssemblySetting class (http://help.autodesk.com/view/CIV3D/2020/ENU/?guid=8655c4e7-c02f-26cd-899b-8ea6f86ede24) and rebuild my corridor using my code below. However this seems to have no effect on the corridor and purely just rebuilds it without applying the AssemblySetting. I’m pretty sure the issue lies with the way I set the AppliedAssemblySetting.AppliedAtHorizontalGeometryPoints property but i’m not too sure.

def CreateCorridors(CorridorNames, AlignmentID, Assembly):

with adoc.LockDocument():

    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
    
    
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
             
            align = t.GetObject(AlignmentID, OpenMode.ForRead)
            
            profileID = align.GetProfileIds()
            
            NewCorridorID = 0
            newcorr = 0
            
            CivilDocument = CivilApplication.ActiveDocument
            
            NewCorridorID = CivilDocument.CorridorCollection.Add(CorridorNames, "Test", AlignmentID, profileID[0], "Test", Assembly,)               
            
            newcorr = t.GetObject(NewCorridorID, OpenMode.ForWrite)
            
            class AppliedAssemblySetting:
                AppliedAtHorizontalGeometryPoints = True
            
            BLCollection = newcorr.Baselines                
            
            regions = BLCollection[0].BaselineRegions
            
            settings = regions[0].AppliedAssemblySetting
            newcorr.Rebuild()
            
            t.Commit()
            pass                
return

Alternatively setting and applying the property using the following code would result in the error “AttributeError: static property ‘AppliedAtHorizontalGeometryPoints’ of ‘AppliedAssemblySetting’ can only be assigned to through a type, not an instance”

with adoc.LockDocument():

    with adoc.Database as db:

        with db.TransactionManager.StartTransaction() as t:
    
    
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
             
            align = t.GetObject(AlignmentID, OpenMode.ForRead)
            
            profileID = align.GetProfileIds()
            
            NewCorridorID = 0
            newcorr = 0
            
            CivilDocument = CivilApplication.ActiveDocument
            
            NewCorridorID = CivilDocument.CorridorCollection.Add(CorridorNames, "Test", AlignmentID, profileID[0], "Test", Assembly,)               
            
            newcorr = t.GetObject(NewCorridorID, OpenMode.ForWrite)
            
            AppliedAssemblySetting.AppliedAtHorizontalGeometryPoints = True
            
            BLCollection = newcorr.Baselines                
            
            regions = BLCollection[0].BaselineRegions
            
            settings = regions[0].AppliedAssemblySetting
            newcorr.Rebuild()
            
            t.Commit()
            pass                
return

I’m really stuck with this one and would very appreciate a helping hand !

1 Like

I don’t think you can set the frequency that way. It only says “get” not “get or set”.

Could you just set up the drawing/template so the command settings have the correct frequency options that you want?

Yeah that’s correct - but I’m looking to change ApppliedAssembySetting. AppliedAtHorizontalGeometryPoints found here http://help.autodesk.com/view/CIV3D/2020/ENU/?guid=8655c4e7-c02f-26cd-899b-8ea6f86ede24 which is a “sub-property” of AppliedAssemblySetting and can be set. Changing the command/drawing settings has no effect on corridors created with Python/API

Oh yeah. Thanks. I see that now. Was looking at the wrong class.

My bad - I wasn’t clear enough in my original post ! It looks like something so simple to achieve but I just cant get my head around what I’m doing wrong

This worked for me.

        with adoc.LockDocument():
        with adoc.Database as db:
            with db.TransactionManager.StartTransaction() as t:
                
                corid = civdoc.CorridorCollection[corridor]
                cor = t.GetObject(corid, OpenMode.ForWrite)
                bl = cor.Baselines[baseline]
                blr = bl.BaselineRegions[baselineRegion]
                sets = blr.AppliedAssemblySetting
                sets.AppliedAtHorizontalGeometryPoints = True
               	
                t.Commit()
2 Likes

This worked perfectly - Thanks a lot for your help Keith !