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.
Solved! Go to Solution.
Solved by michael_robertson. Go to Solution.
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)
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:
Add subassembly to assembly:
It's awesome - it really working!
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(0, 0, 0) Dim location2 As New Autodesk.AutoCAD.Geometry.Point3d(10, -0.2, 0) 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:
Thanks a lot!
Thanks for sharing your code, this is something we will probably doing pretty soon.
Mike
Can't find what you're looking for? Ask the community or share your knowledge.