CivilObject.SetName doesn't allow characters in string but Civil3D does

Hi All,

I’m reassigning pipe structure names and using the civilobjects.setname node. The error being called out is

Warning: CivilObject.SetName operation failed.
Error: string contents for attribute ‘FRP3/SW/R/12B/4’ contain invalid characters. The following characters are not valid in object names: <>/":;=|,*?`

because there are forward slashes in the name. Does anyone have a work around other than omitting the forward slash? If I manually input the name in civil3d then it allows the forward slash. Perhaps another node suggestion to rename structures?

Hi

Maybe this is help you

Thanks @hosneyalaa, it looks like it might work but I don’t know nearly enough about code to apply it.

I am not trying this before
But I will try for you

Tomorrow…

hi @sobeshan.pillay
try

import sys
import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')
clr.AddReference('AeccPressurePipesMgd')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

from System.Collections.Generic import Dictionary
from System import *
#from System.Linq import *
#from System import Linq
adoc = Application.DocumentManager.MdiActiveDocument
cdoc = CivilApplication.ActiveDocument

from Autodesk.DesignScript.Geometry import *


def dynamic_oStruct(dynamics):
	
	global adoc
	global cdoc
	
	output = []
	

	if not dynamics:
		return
	
	if not isinstance(dynamics, list):
		dynamics = [dynamics]

	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
				for dynam in dynamics:
					vals = []
					
					StructId = dynam.InternalObjectId
					Struct = t.GetObject(StructId, OpenMode.ForWrite)
					oStruct = Struct.AcadObject
					oStruct.Name = oStruct.Name + " / test!"
					output.append(oStruct.Name)
					
						
				t.Commit()
	return output 		


OUT = dynamic_oStruct(IN[0])

Hi @sobeshan.pillay ,

Perhaps this has something to do with escape characters, how exactly are you giving the name input?

Hi Daan,

I’m calling it from an excel sheet where an example of the name is "FA/PR/2. The same script works when changing the excel values to text or numbers.