Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ImportSubassembly API for custom subassembly, error?

15 REPLIES 15
SOLVED
Reply
Message 1 of 16
zzffxx
9091 Views, 15 Replies

ImportSubassembly API for custom subassembly, error?

Hi,

When I use ImportSubassembly API to import my subassembly created by Autodesk Subassembly Composer  into my civil project, it reports error-"eFilerError".

 

the code like this:

atcFile = @"D:\9f92eaa4ef514ac982518852e1169932.atc";
itemId = "ab660722-c69d-4ade-b373-0e9f99c94e55";
SubassemblyCollection subassemblyCollection = cDoc.SubassemblyCollection;
ObjectId subassemblyId = subassemblyCollection.ImportSubassembly("TestSubassembly", atcFile, itemId, this.doc.Editor.GetPoint("Select import subAssembly location").Value);

 

However, it is OK if to import subassembly provided by Cilvil 3D.

why? Thanks if someone could help me.

15 REPLIES 15
Message 2 of 16
Partha.Sarkar
in reply to: zzffxx

Hi,

 

Two things to check here -

 

1. Can you use your custom subassembly using Civil 3D UI tools ?

2. Check the GUID in the itemId

 

Thanks,

Partha Sarkar

Autodesk



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 3 of 16
zzffxx
in reply to: Partha.Sarkar

Dear Sarkar:

Thanks for your attention.

 

I have checked my custom subassembly using Civil 3D UI tools and it is fine. Another, the GUID is just from atc file. So, it seems the problem is not here.

 

I'll describe my testing process in detail as follows:

 

Case1:

First, I import my custom subassembly using ImportSubAssembly API from atc file in the "channel001" folder(see figure1). The "eFilerError" Exception is reported.

 

Case2:

Second, I directly import my custom subassembly using Civil3D UI tools, no problem happens.

 

Case3:

After using UI tools, I find Civil3D built a new folder(see figure2 ).

Compared the two figures, two new files are created. What are they?

 

Now, I call the ImportSubAssembly API again to import my custom subassembly from atc file in the new folder.Civil 3D reports information(see figure3. sorry, it is Chinese version):

 

In this case, the "eFilerError" Exception is no longer reported. But I can't get my custom subassembly data correctly  yet.

 

The ImportSubassembly API is new API provided by Civil 2014. I appreciate that civil 3D team has released so useful API.

 

Finally, I expect further help about this. Thanks.

Message 4 of 16
Partha.Sarkar
in reply to: zzffxx

I will look into this and get back to you soon.

 

Thanks,



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 5 of 16
AppleGao
in reply to: zzffxx

Hi,

 

I checked your test data, and found two problems.

1.In 316c01080d0c427f91d62dd17188ead5.atc, please use "Double" instead of "double" for DataType, or else these parameters will not be added into subassembly;

2.I used your code and test data to import subassembly channel001,and it failed to use type channel001 to create an instance.

The exception message is "The type initializer for‘Subassembly.channel001’threw an exception.". I used reflector and didn't see any subassembly in 316c01080d0c427f91d62dd17188ead5.dll, please see reflectorImage.png. And I used tool IL DASM to open this dll and found:

.class private auto ansi Subassembly.channel001
extends [mscorlib]System.Object
{
} // end of class Subassembly.channel001

And I think it should be public rather than private, for example:

.class public auto ansi Subassembly.BasicBarrier
extends Subassembly.SATemplate
{
} // end of class Subassembly.BasicBarrier

But I am not sure if it's only place should be changed to public, please check other method or definition,referring to C3DStockSubassemblies.dll.

 

If there is still some problems, please let me know.Thanks.

 

Regards,

Apple

 

Message 6 of 16
Partha.Sarkar
in reply to: AppleGao

Hi zzffxx,

 

One of my colleagues investigayed your customsubassembly issue and reponded here.

Please check the above details and let us know if that helps in resolving the issue you reported here.

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 7 of 16
zzffxx
in reply to: zzffxx

Hi,

AppleGao,

I checked my program according to what you instruct.

You are right about the first problem. As I changed "double" into "Double", the parameters were added successfully.

But,on the second problem we had different results. I used reflector 7.0 and can see subassembly item , see figure 1.

 

No matter what the problems are, I must point out that the test data (contain *.atc,*.dll and so on ) is from *.pkt file which is automatically created by Autodesk Subassembly Composer tool. The problems like "double/Double" or ".class private/public" are completely out of my control because it has existed since created by Autodesk Subassembly Composer tool.

How could I modify a dll file?

 

I think ImportAssembly/ImportSubAssembly APIs should provide seamless connection with Subassembly Composer tool.

 

thanks.

 

 

Message 8 of 16
AppleGao
in reply to: zzffxx

Hi,

I discussed the problem with the developer who exposed this API. And this API is not for importing subassembly from file atc and dll.
It is just for adding subassembly to drawing when subassembly is already imported. It's action is like dragging subassembly from tool palette to a drawing in UI.
I think the name for this API is not so appropriate, which will lead misunderstanding easily. We should have named it like AddSubassemblyToDrawing. And sorry for any inconvenient.

Regards,
Apple

Message 9 of 16
Partha.Sarkar
in reply to: AppleGao

Thanks for the confirmation Apple !

 

Cheers,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 10 of 16
zzffxx
in reply to: AppleGao

Hi,
Apple.
Now I see. Thank for your jobs.
Message 11 of 16
rasmusfb
in reply to: AppleGao

I have managed to import my subassemblies (which I have made using VB.NET) into the Tool Palette, and I manage to put them into the drawing using the C3D UI (i.e. drag them from the Tool Palette). Now, I would like to use the ImportSubassembly API to do the same (put them into the drawing). However, when using it (specifying the atc-file located in %APPDATA%\Autodesk\C3D 2015\enu\Imported Tools\, the subassy-name and item id from atc-file and location), I get the following exception:

"Object reference not set to an instance of an object".

 

Stack trace is as follows:

at System.Xml.XmlAttributeCollection.get_ItemOf(String name)
at Autodesk.Civil.DatabaseServices.SubassemblyCollection.importParamToSubassembly(Subassembly SA, XmlNode nodeParam, Int32 displayOrder)
at Autodesk.Civil.DatabaseServices.SubassemblyCollection.importParamsToSubassembly(AeccDbSubassembly* pDbSubassembly, XmlNode nodeSA)
at Autodesk.Civil.DatabaseServices.SubassemblyCollection.ImportSubassembly(String subassemblyName, String atcFilePath, String itemId, Point3d location)

 

Do I still not use the ImportSubassembly API the way it is intended?

Message 12 of 16
rasmusfb
in reply to: rasmusfb

Solved.
Message 13 of 16
Kélcyo
in reply to: rasmusfb

@rasmusfb You could provide the sample code which you were able to import into the palette.
Message 14 of 16
Kélcyo
in reply to: rasmusfb

What is the solution to this task?
Message 15 of 16
drbohlav
in reply to: rasmusfb

Hi, what is the solution please?

Is there any sample code?

I am looking for Python code?

When I tried to use this api, I had error, couldn't find actFile itemId. Is here anyone who was successful?

Best wishes 

Lukas 

Message 16 of 16
gleeuwdrent
in reply to: drbohlav

For attaching a subassembly in this way you need first to import the subassembly in the toolpalette, and then use the .atc file of the toolpalette in your code, not the .atc file of the subassembly which is located here:

%APPDATA%\Autodesk\C3D 2015\enu\Imported Tools\

 

The toolpalette atc files are located here:

%APPDATA%\Roaming\Autodesk\C3D 2018\enu\Support\ToolPalette\Palettes

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report