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: 

Creating subassembly using .NET

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Alexey.Terno
2446 Views, 7 Replies

Creating subassembly using .NET

Is it possible to create subassembly from C3D Stock Subassemblies.dll programmatically using .NET?
I need call procedure (BasicLane for example), set all input parameters and create subassembly in drawing.

7 REPLIES 7
Message 2 of 8
Jeff_M
in reply to: Alexey.Terno

Yes. The source code for the Stock Subassemblies is in the C:\Program Files\Autodesk\Autodesk AutoCAD Civil 3D 2014\Sample\Civil 3D API\C3DStockSubAssemblies folder.

Jeff_M, also a frequent Swamper
EESignature
Message 3 of 8
Alexey.Terno
in reply to: Jeff_M

Yes, I know it but I need call procedure of this DLL from another DLL.
Message 4 of 8

Alex,

Not sure exactly what you are asking:

> Create a new subassembly

> Use a stock subassembly within a custom subassembly

> Programmatically create an assembly using stock subassembly

 

What version of C3D are you using? (the answer may vary depending on version)

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer
Message 5 of 8

I need programmatically create new assembly using stock subassembly.
C3D2014
VB.NET 2010 - just in case 🙂
Message 6 of 8

I haven't done this myself but I know it is possible from software we had written for us.

 

Here's the methods:

Import stock subassemly:

http://docs.autodesk.com/CIV3D/2014/ENU/API_Reference_Guide/html/648aeb2b-8729-3cc2-beb6-0a2ce6f24b8...

 

Add subassembly to assembly:

http://docs.autodesk.com/CIV3D/2014/ENU/API_Reference_Guide/html/73cadec3-9dee-8246-fdf8-652428c9ef2...

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer
Message 7 of 8

It's awesome - it really working! Smiley Very Happy
Here working test routine:

 

        Dim a_CivilDoc As CivilDocument
        a_CivilDoc = CivilApplication.ActiveDocument
 
        Dim saname As String = "C:\Documents and Settings\All Users\Application Data\Autodesk\C3D 2010\rus\C3DStockSubassemblies.dll"
        Dim classname As String = "Subassembly.BasicLane"
        Dim location As New Autodesk.AutoCAD.Geometry.Point3d(000)
        Dim location2 As New Autodesk.AutoCAD.Geometry.Point3d(10, -0.20)
 
        Dim q_SubassemblyId As ObjectId
        q_SubassemblyId = a_CivilDoc.SubassemblyCollection.ImportStockSubassembly(saname, classname, location)
 
        Dim q_SubassemblyId2 As ObjectId
        q_SubassemblyId2 = a_CivilDoc.SubassemblyCollection.ImportStockSubassembly(saname, classname, location2)
 
        Dim q_Subassembly As Subassembly
        Dim q_Subassembly2 As Subassembly
        Dim q_Assembly As Assembly
 
        Using a_Transaction As Transaction = _
            HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction
 
            q_Subassembly = a_Transaction.GetObject(q_SubassemblyId, OpenMode.ForWrite)
            q_Subassembly2 = a_Transaction.GetObject(q_SubassemblyId2, OpenMode.ForWrite)
 
            Dim q_Parameters As ParamDoubleCollection
            q_Parameters = q_Subassembly.ParamsDouble
 
            For i = 0 To q_Parameters.Count - 1
                If q_Parameters(i).DisplayName = "509" Then
                    q_Parameters(i).Value = 5
                End If
            Next
 
            q_Assembly = a_Transaction.GetObject(a_CivilDoc.AssemblyCollection(0), OpenMode.ForWrite)
            q_Assembly.AddSubassembly(q_Subassembly.Id)
            q_Assembly.InsertSubassemblyAfter(q_Subassembly2.Id, q_Subassembly.Points(3))
 
            a_Transaction.Commit()
 
        End Using

 And result:

Assambly

 

Thanks a lot!

Message 8 of 8

Thanks for sharing your code, this is something we will probably doing pretty soon.

 

Mike

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report