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"); 

source: https://knowledge.autodesk.com/support/autocad-civil-3d/learn-explore/caas/cloudhelp/cloudhelp/2017/enu/civil3d-devguide/files/guid-f620df41-7df3-450f-8c2a-a92deb1f9e9e-htm.html

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

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -