c# - Creating Civil 3D Alignment in .Net throws "Alignment ID is invalid" error -
i developing ifc (industry foundation classes) import/export add-in civil 3d, publish open source later month). export function works fine already. however, still don't quite understand how create objects in civil 3d using .net. add-in written in c#.
i tried following, official autodesk example:
// uses existing alignment style named "basic" , label set style named "all labels" (for example, // _autocad civil 3d (imperial) ncs.dwt template. call fail if named styles // don't exist. // uses layer 0, , no site (objectid.null) objectid testalignmentid = alignment.create(doc, "new alignment", objectid.null, "0", "basic", "all labels");
however, whenever try run code, following error message: "invalid alignment id.". code looks following:
var civildatabase = application.documentmanager.mdiactivedocument.database; var civildocument = civilapplication.activedocument; using (transaction civiltransactionmanager = civildatabase.transactionmanager.starttransaction()) { objectid civilalignment = alignment.create(civildocument, "myname", "" , "0", "basic", "all labels");
i tried replace "" gives site alignment null or objectid.null, both not work , replacing objectid.null prevent me compiling.
anyone knows error comes from?
looking @ documentation alignment methods, more following overload:
public static objectid create( civildocument document, string alignmentname, string sitename, string layername, string stylename, string labelsetname )
it says:
system.argumentexception
the name of drawing, layer, style, labelset or site invalid. name of alignment exists.
so seems of names not correct. more robust approach, may list styles , name or objectid there. siteless alignment, can pass string.empty
sitename
parameter.
Comments
Post a Comment