Hi,
Can anyone please help me in removing corridor baseline region via dynamo.
I have tried looking for this kind of node in Civil 3D toolkit but it seems no node available to remove baseline region.
Thanks
Hi,
Can anyone please help me in removing corridor baseline region via dynamo.
I have tried looking for this kind of node in Civil 3D toolkit but it seems no node available to remove baseline region.
Thanks
Hi @hosneyalaa
Thanks for this information, it looks there is possibility.
But I donât have much knowledge on dynamo scripting.
Can anyone one please create dynamo script?
Thanks and much appreciated.
Hi All,
I have tried the below code but getting errors can anyone please correct me
import clr
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â)
clr.AddReference(âCivil3DNodesâ)
import sys
sys.path.append(âC:\Program Files (x86)\IronPython 2.7\Libâ)
import os
import math
from System import *
from System.IO import *
from System.Collections.Specialized import *
from System.Windows.Forms import MessageBox
import Autodesk.AutoCAD.ApplicationServices.Application as acapp
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 *
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
from Autodesk.Civil.DynamoNodes import Alignment as DynAlignment
adoc = acapp.DocumentManager.MdiActiveDocument
ed = adoc.Editor
civdoc = CivilApplication.ActiveDocument
corridor = IN[0]
baseline = IN[1]
baselineRegion = IN[2]
def removeRegion:
global adoc
global ed
global civdoc
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]
baselineRegionColl.Remove("RG - Ass_PRS - (78)");
t.Commit()
except Exception() as ex:
MessageBox.Show(ex.message)
return result
OUT = removeRegion.
Drop the semicolon on this line.
Also, this script would be a lot more useful if the region name was an input instead of being hard-coded.
Hi @mzjensen
Thank you so much for your help.
I am getting some indent error msg. as below
**Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. **
unexpected indent
also as per your advice, I have made little change, I am not sure I have coded correct or not can you please correct me if I am wrog somewhere.
corridor = IN[0]
baseline = IN[1]
baselineRegion = IN[2]
def removeRegion:
global adoc
global ed
global civdoc
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]
baselineRegionColl.Remove(baselineRegion)
t.Commit()
except Exception() as ex:
MessageBox.Show(ex.message)
return result
OUT = removeRegion
Weâve talked about this previously in a private message. Iâll repost that here for others to reference:
Python has special rules for the indentation of each line. In most other languages, youâll see that the end of each line is indicated with a specific character. For example, in C# you always end a line with a ;. Thatâs how the computer knows to move from one line to the next in the execution process.
But as you can see with Python, there are no specific characters and the end of each line, so how does the computer know when to move from one line to the next? The answer is the indentation of each line. The official Python style guide calls to use 4 spaces for each indentation level, but you can also use the tab key. Hereâs more to read:
https://www.scaler.com/topics/python/indentation-in-python/
I canât tell what the issue is by glancing at it quickly, so all I can say is to check each line and make sure you arenât mixing tabs and spaces, and that each line has the amount of indentation that it should. For example, the entire block starting at with adoc.LockDocument():
seems to be indented more than it should.
This can often be an issue when copying/pasting code from somewhere else.
@ansarimdnazir besides the indention rules that @mzjensen has mentioned, you also have an âexceptâ clause without a âtryâ clause before. I donât know if this is possible in Python (iâve never seen a âtry exceptâ without the keyword âtryâ), but maybe you should also check for that. Additionally, all code that belongs to the removeRegion function should be indented