Is there a way to automate .ipt to adsk conversion? I believe this can be done by ilogic or macro but I dont know how.
Solved! Go to Solution.
Solved by lmc.engineering. Go to Solution.
Solved by lmc.engineering. Go to Solution.
Hi @Anonymous
You can achieve this using the following:
SyntaxEditor Code Snippet
Dim oDoc As Document = ThisApplication.ActiveDocument CompDef = oDoc.ComponentDefinition FullFileName = "YourFilePath\YourFileName.adsk" CompDef.BIMComponent.ExportBuildingComponent(FullFileName)
If you go to Help>Programming/API Help and search 'BIMComponent', you'll find everything you need there.
thank you @lmc.engineering. Do you know how to set the file name automatically to use the same as source name?
\YourFileName.adsk"
You can use any of the below for this.
SyntaxEditor Code Snippet
'''The below gets the file path and file name
Dim FileSource As String = ThisDoc.PathAndFileName(False) ''' False leaves off the extension (ie .ipt)
'''The below gets just the file name Dim FileName As String = ThisDoc.FileName(False) '''False leaves off the extension
'''The below gets just the file path Dim FilePath As String = ThisDoc.Path
It is not getting the file name, it write the code exactly as file name.
SyntaxEditor Code Snippet
Dim oDoc As Document = ThisApplication.ActiveDocument CompDef = oDoc.ComponentDefinition FullFileName = "ThisDoc.FileName(False) 'without extension.adsk" CompDef.BIMComponent.ExportBuildingComponent(FullFileName)
Ok, so I can see where the confusion has come from. It was probably a bit misleading with the parameter 'FullFileName'. What we actually need is the file path and file name, as below
SyntaxEditor Code Snippet
Dim oDoc As Document = ThisApplication.ActiveDocument CompDef = oDoc.ComponentDefinition FullFilePathandName = ThisDoc.PathAndFileName(False) FileFileName = FullFilePathandName & ".adsk" CompDef.BIMComponent.ExportBuildingComponent(FullFileName)
Hi @lmc.engineering.
Is it possible to have an option for ucs? I have consistent ucs name of each file.
Hi @Anonymous
You can export a BIM component with a user coordinate system using the following:
Dim oDoc As Document = ThisApplication.ActiveDocument CompDef = oDoc.ComponentDefinition Dim oBIMOrientType As BIMComponentOrientationTypeEnum oBIMOrientType = kUserCoordinateSystemOrientationType FullFileName = "C:\Temp\Test.adsk" CompDef.BIMComponent.ExportBuildingComponent(FullFileName)
If you need to create and set the UCS before export, you can use this.
Sub Main() CreateUCSBy3Points() End Sub Sub CreateUCSBy3Points() Dim oDoc As Document = ThisApplication.ActiveDocument ' Set a reference to the PartComponentDefinition object Dim oCompDef As PartComponentDefinition oCompDef = oDoc.ComponentDefinition Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry ' Create 3 workpoints to define the origin, x-direction and y-direction points Dim oWorkPoint1 As WorkPoint oWorkPoint1 = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(2, 0, 0)) Dim oWorkPoint2 As WorkPoint oWorkPoint2 = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(4, 0, 0)) Dim oWorkPoint3 As WorkPoint oWorkPoint3 = oCompDef.WorkPoints.AddFixed(oTG.CreatePoint(2, 2, 0)) ' Create an empty definition object Dim oUCSDef As UserCoordinateSystemDefinition oUCSDef = oCompDef.UserCoordinateSystems.CreateDefinition ' Set it to be based on the 3 points Call oUCSDef.SetByThreePoints(oWorkPoint1, oWorkPoint2, oWorkPoint3) ' Create the UCS Dim oUCS As UserCoordinateSystem oUCS = oCompDef.UserCoordinateSystems.Add(oUCSDef) ExportBIM(oDoc) End Sub Sub ExportBIM(oDoc As Inventor.Document) 'Dim oDoc As Document = ThisApplication.ActiveDocument CompDef = oDoc.ComponentDefinition Dim oBIMOrientType As BIMComponentOrientationTypeEnum oBIMOrientType = kUserCoordinateSystemOrientationType FullFileName = "C:\Temp\Test.adsk" CompDef.BIMComponent.ExportBuildingComponent(FullFileName) End Sub
Is this what you were asking?
Hi @lmc.engineering,
I found your solution, but I am pretty sure that it does not work.
Your code does not really set the OrientationType, the assignment is missing.
When I try to assign the OrientationType I get an exception.
I have already created a thread:
https://forums.autodesk.com/t5/inventor-customization/export-rfa-with-ucs/td-p/9465092
Could you please do me a favor and check this issue?
Regards Andreas
Can't find what you're looking for? Ask the community or share your knowledge.