Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rotate Part and translate the part

0 REPLIES 0
Reply
Message 1 of 1
2020mme013
132 Views, 0 Replies

Rotate Part and translate the part

Hi community I want to Rotate the part which is in the co-ordinate as shown, Part name is ib06 which is in wrong position, Please anyone help me to do it match with face of the left assembly part, as per my understanding (x,y,z) rotate as (90,0,270) then it would be in correct place.

I have commented line to do this rotation for particular part. 

 

 

AddReference "System.Xml"
Imports System.Xml
Sub Main()
 
CleanUpAssy()
 
Trace.TraceInformation("Before load XML") 'Trace.TraceInformation = String for debugging log that can be retrieved from the Forge Server
 
Dim FilePath As String
FilePath = ThisDoc.Path()
FilePath = FilePath.Replace("\unpacked", "")
 
Select LCase(System.Environment.UserName) 
Case "518197" 'Windows id for running lokal
Dim oFileDialog As Inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDialog)
 
oFileDialog.ShowOpen()
 
If oFileDialog.FileName <> "" Then
oFile = oFileDialog.FileName
Else
iLogicVb.UpdateWhenDone = True
Exit Sub
End If
Case Else
oFile = FilePath & "\BV06-03-076045-01.xml"
End Select
 
Trace.TraceInformation(oFile) 'Debug XML-file
 
oRead = System.IO.File.OpenText(oFile)
 
'read the file
oRead = System.IO.File.OpenText(oFile)
EntireFile = oRead.ReadToEnd()
oRead.Close()
 
Dim doc As XmlDocument = New XmlDocument()
 
doc.LoadXml(EntireFile) 
 
Trace.TraceInformation("XML loaded") 'Debug XML-file OK
 
Call eSyberValve(doc)
 
'Exit Sub
 
Select LCase(System.Environment.UserName) 
Case "518197"
oDwg = MessageBox.Show("Generete drawing?", "Drawing", MessageBoxButtons.YesNo)
If oDwg = vbNo Then
Exit Sub
End If
Case Else
End Select
 
'Send drawing parameters to drawing
DrawingParameters()
 
'Create simplified part
CreateSimplifiedPart()
 
 
Dim oDoc As DrawingDocument = ThisServer.Documents.Open(ThisDoc.Path & "\generated.dwg",True)
'run rule in the drawing document
auto = iLogicVb.Automation
auto.RunRuleWithArguments(oDoc, "eSyber", oRuleArguments)
 
' Select LCase(System.Environment.UserName) 
' Case "518197"
' oDwg = MessageBox.Show("Generete drawing?", "Drawing",MessageBoxButtons.YesNo)
' If oDwg = vbNo Then
' Exit Sub
'End If
'Case Else
'End Select
 
''Send drawing parameters to drawing
 
 
' 'Create simplified part
' CreateSimplifiedPart()
 
' 'Save step-file
' SaveStep() 
 
' '[Sends parameters to drawing
' Dim oRuleArguments As Inventor.NameValueMap = ThisServer.TransientObjects.CreateNameValueMap()
 
' Dim seSyber_Identity As String = SharedVariable("eSyber_Identity")
'oRuleArguments.Add("eSyber_Identity", seSyber_Identity)
 
' Dim sState As String = SharedVariable("State")
'oRuleArguments.Add("State", sState)
 
' Dim sStateChangedDate As String = SharedVariable("StateChangedDate")
'oRuleArguments.Add("StateChangedDate", sStateChangedDate)
 
' Dim sApplication As String = SharedVariable("Application")
'oRuleArguments.Add("Application", sApplication)
 
' Dim sCustomerProductID As String = SharedVariable("CustomerProductID")
'oRuleArguments.Add("CustomerProductID", sCustomerProductID)
 
' Dim sCustomer As String = SharedVariable("Customer")
'oRuleArguments.Add("Customer", sCustomer)
 
'' Dim sCusPartNo As String = SharedVariable("CusPartNo")
''oRuleArguments.Add("CusPartNo", sCusPartNo)
 
' Dim sTablePort As String = SharedVariable("TablePort")
'oRuleArguments.Add("TablePort", sTablePort)
 
 
 
'']
 
' Dim oDoc As DrawingDocument = ThisServer.Documents.Open(ThisDoc.Path & "\generated.dwg",True)
' 'run rule in the drawing document
' auto = iLogicVb.Automation
'auto.RunRuleWithArguments(oDoc, "eSyber", oRuleArguments)
 
End Sub
 
Sub eSyberValve(Doc As XmlDocument)
Trace.TraceInformation("Start Sub eSyberValve")
 
'Valve Configuration information
SharedVariable("Product") = Doc.ChildNodes(1).SelectNodes("Product")(0).InnerXml.ToString()
SharedVariable("eSyber_Identity") = Doc.ChildNodes(1).SelectNodes("Name")(0).InnerXml & "-" & Doc.ChildNodes(1).SelectNodes("Revision")(0).InnerXml
SharedVariable("State") = Doc.ChildNodes(1).SelectNodes("State")(0).InnerXml
SharedVariable("StateChangedDate") = Left(Doc.ChildNodes(1).SelectNodes("StateChangedDate")(0).InnerXml, 10)
SharedVariable("Application") = XmlValue(Doc, "valve", "P06")
SharedVariable("Customer") = XmlValue(Doc, "valve", "D19C")
SharedVariable("CustomerProductID") = XmlValue(Doc, "valve", "P08")
 
' SharedVariable("Port_Type") = XmlValue(Doc, "valve", "P08")
 
MessageBox.Show("Product: " & SharedVariable("Product") & vbLf & "eSyber Identity: " & SharedVariable("eSyber_Identity") & vbLf & "State: " & SharedVariable("State") _ 
& vbLf & "Creation date: " & SharedVariable("StateChangedDate") & vbLf & "[P06] Application: " & SharedVariable("Application") & vbLf & "[D19C] Customer name: " & SharedVariable("Customer") & vbLf & "[P08] Customers product Id: " & SharedVariable("CustomerProductID"), "GENERAL DATA")
 
 
Select SharedVariable("Product")
Case ""
Case Else
PortTable = PortTable & BV06_Inlet(Doc)
PortTable = PortTable & BV06_Section(Doc)
' PortTable = PortTable & BV06_Outlet(Doc)
End Select
 
SharedVariable("TablePort") = PortTable
 
Trace.TraceInformation("End Sub eSyberValve")
End Sub
 
Function BV06_Inlet(Doc As XmlDocument)
Trace.TraceInformation("Start Function BV06_Inlet")
 
Dim AddToAssy As ManagedComponentOccurrence 'AddToAssy = Adds components in specific coordinate system
Dim IsGrounded As Boolean = True
Dim oPNT As DocumentUnitsPoint
Dim oPath As String
Dim PartName As String
 
PortTable = "INLET SECTION:;;;"
 
oPNT = ThisAssembly.Geometry.Point(-2.620, 0, 0.615)
oPath = ThisDoc.Path & "\Parts\"
 
MessageBox.Show("[P2010] Inlet Section Type: " & XmlValue(Doc, "inlet", "P2010") & vbLf & "[P2012] Inlet Body Type: " & XmlValue(Doc, "inlet", "P2012") & vbLf & _
"[P2020] Inlet Relief Adjustment Range: " & XmlValue(Doc, "inlet", "P2020") & vbLf & "[P2030] Inlet Unloader Override: " & XmlValue(Doc, "inlet", "P2030") _
& vbLf & "[P2040] Unloader Coil Voltage: " & XmlValue(Doc, "inlet", "P2040"), "INLET OPTIONS")
 
'---------------------------------------------------------------------------------------------------------
'[P2012] Inlet Body Type
PartName = "Bodies\" & XmlValue(Doc, "inlet", "P2012")
AddToAssy = Components.Add(PartName & ":In", oPath & PartName & ".ipt", oPNT, IsGrounded)
 
SharedVariable("OffsetX") = 0
 
Select XmlValue(Doc, "inlet", "P2012")
Case "so6t"
SharedVariable("OffsetX") = 0.675
Case "6t", "i6t", "si6t"
SharedVariable("OffsetX") = 1.875
Case "ib06"
SharedVariable("OffsetX") = 0
'////////////----------------FOR THIS PART ROTATION REQUIRED-----------///////////////
Case Else
SharedVariable("OffsetX") = 1.925
End Select
']
'[P2010] Inlet Section Type
Select XmlValue(Doc, "inlet", "P2010")
Case "-"
Case "mr"
AddPartToPort("mr06", "P2010_B", "Front")
Case "u"
Select XmlValue(Doc, "inlet", "P2030")
Case "/"
AddPartToPort("u06", "P2010_B", "Front")
Case "m"
AddPartToPort("um06", "P2010_B", "Front")
Case "e"
AddPartToPort("ue06", "P2010_B", "Front")
End Select
Case "ur"
AddPartToPort("mr06", "P2010_A", "Back")
Select XmlValue(Doc, "inlet", "P2030")
Case "/"
AddPartToPort("u06", "P2010_B", "Front")
Case "m"
AddPartToPort("um06", "P2010_B", "Front")
Case "e"
AddPartToPort("ue06", "P2010_B", "Front")
End Select
End Select
']
'[P2040] Unloader Coil Voltage
Select XmlValue(Doc, "inlet", "P2040")
Case "d012", "d024"
AddPartToPort("bvc06", "P2040", "Front")
End Select
']
Return PortTable
 
Trace.TraceInformation("End Function BV06_Inlet")
End Function
 
Function BV06_Section(Doc As XmlDocument)
Trace.TraceInformation("Start Function BV06_Section")
 
Dim AddToAssy As ManagedComponentOccurrence
Dim IsGrounded As Boolean = True
Dim oPNT As DocumentUnitsPoint
Dim oPath As String
Dim PartName As String
Dim SectionNo As Integer
Dim NoOfSection As String
 
PortTable = PortTable & "WORK SECTION:;;;" 
 
oPath = ThisDoc.Path & "\Parts\"
 
SharedVariable("QtyOfSections") = Doc.ChildNodes(1).SelectNodes("Children")(0).ChildNodes.Count
 
For SectionNo = 1 To SharedVariable("QtyOfSections")
NoOfSection = SectionNo.ToString
 
oPNT = ThisAssembly.Geometry.Point(SharedVariable("OffsetX"), 0, 0)
 
MessageBox.Show("[P1050] Body Type: " & XmlValue(Doc, NoOfSection, "P1050") & vbLf & "[P5020] Spool Type: " & XmlValue(Doc, NoOfSection, "P5020") & vbLf & "[P5031] Bottom Stack-On Type: " & XmlValue(Doc, NoOfSection, "P5031") _
& vbLf & "[P5041] Top Stack-On Type: " & XmlValue(Doc, NoOfSection, "P5041"), "SPOOL SELECTION " & NoOfSection)
 
Try
'---------------------------------------------------------------------------------------------------------
'[P1050] Body Type
PartName = "Bodies\" & XmlValue(Doc, NoOfSection, "P1050")
AddToAssy = Components.Add(PartName & ":S" & NoOfSection, oPath & PartName & ".ipt", oPNT, IsGrounded)
 
Select XmlValue(Doc, NoOfSection, "P1050")
Case "6t", "i6t", "si6t"
SharedVariable("OffsetX") = SharedVariable("OffsetX") + 1.875
Case Else
SharedVariable("OffsetX") = SharedVariable("OffsetX") + 1.925
End Select
']
Catch
End Try
Next
 
 
Return PortTable
 
Trace.TraceInformation("End Function BV06_Section")
End Function
 
Function XmlValue(Doc As XmlDocument, SectionType As String, SearchPos As String)
Dim PosNo, PosValue As String
 
 
Select LCase(SectionType)
Case "valve", "inlet", "outlet"
SectionNo = 0
NodeAdress = Doc.ChildNodes(1)
Case Else
SectionNo = CDblAny(SectionType) - 1
NodeAdress = Doc.ChildNodes(1).SelectNodes("Children/ConfigurationDto")(SectionNo)
End Select
 
NodesCount = NodeAdress.SelectNodes("Parameters")(0).ChildNodes.Count
SectionType = NodeAdress.SelectNodes("Product")(0).InnerXml.ToString() 
 
Select LCase(Left(SearchPos,4))
Case "type"
Return LCase(SectionType)
Case "mach"
Return UCase(MachineFunction)
Case Else
Dim APosNo As String()
Dim A_Variant As String
Dim begr As Integer = 0
PosNo = ""
PosValue = ""
Dim ValueNodeFound As Boolean = False
PosValue = ""
For i = 0 To NodesCount - 1
 
 
PosNo = NodeAdress.SelectNodes("Parameters/ParameterDto")(i).SelectNodes("Name")(0).InnerText.ToString()
If InStr(PosNo, ".") > 0 Then ' SearchPos for MultiChoise pos.
APosNo = Split(PosNo, ".")
If APosNo(0) = SearchPos Then
Try
A_PosValue = NodeAdress.SelectNodes("Parameters/ParameterDto")(i).SelectNodes("Value")(0).InnerText.ToString()
ValueNodeFound = True
Catch
ValueNodeFound = False
End Try
If ValueNodeFound = False Then
Try
A_PosValue = NodeAdress.SelectNodes("Parameters/ParameterDto")(i).SelectNodes("ValueId")(0).InnerText.ToString()
ValueNodeFound = True
Catch
If Input_xmlstring = "?" Then MsgBox("Value / ValueId not found", SearchPos)
End Try
End If
If ValueNodeFound = True And A_PosValue = "true" Then
PosValue = PosValue & "_" & APosNo(1)
End If
End If
Else
If PosNo = SearchPos Then
Try
PosValue = NodeAdress.SelectNodes("Parameters/ParameterDto")(i).SelectNodes("Value")(0).InnerText.ToString()
Catch
PosValue = "-"
End Try
Exit For
End If
End If
Next
End Select
 
 
Select SearchPos 
Case "D19", "D19C", "P06", "P08" 
Return PosValue
Case Else
Return LCase(PosValue)
End Select
 
End Function
 
Sub AddPartToPort(PartName As String, oWPname As String, ViewSide As String)
 
    Dim oAsmCompDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition
    Dim oOccs As ComponentOccurrencesEnumerator = oAsmCompDef.Occurrences.AllLeafOccurrences
Dim oOcc As ComponentOccurrence
Dim oWP As WorkPoint
Dim oWPProxy As WorkPointProxy
Dim oTG As TransientGeometry = ThisServer.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim DegreeConstant As Decimal = (3.14159265358979) / 180
Dim AxisRotation, ConnectorRotation As Decimal
Dim Xaxis, Yaxis, Zaxis As Integer
Dim oOccName1, SectionNo, oMessage, oFullFileName As String
oPath = ThisDoc.Path & "\Parts\StdParts\" 
Xaxis = 0
Yaxis = 0
Zaxis = 0
AxisRotation = 0
ConnectorRotation = 0
oWPname = LCase(oWPname)
 
 
' If System.IO.File.Exists(oPath & "Plugs\" & PartName & ".ipt") = True Then
' oFullFileName = ThisDoc.Path & "\Parts\StdParts\Plugs\" & PartName & ".ipt"
' ConnectorRotation = 0
' oOccName1 = "plugs\"
' Else
oFullFileName = ThisDoc.Path & "\Parts\StdParts\" & PartName & ".ipt"
' ConnectorRotation = 0
oOccName1 = "StdParts\"
' End If
 
Select LCase(ViewSide)
Case "left"
AxisRotation = 0
Zaxis = 1
Case  "front"
AxisRotation = 90 * DegreeConstant 
Zaxis = 1
Case "right"
AxisRotation = 180 * DegreeConstant
Zaxis = 1
Case "back"
AxisRotation = 270 * DegreeConstant
Zaxis = 1
Case "top"
AxisRotation = 90 * DegreeConstant
Yaxis = 1
Case "bottom"
AxisRotation = 270 * DegreeConstant
Yaxis = 1
End Select 
 
AxisRotation = AxisRotation + ConnectorRotation
 
If oWPname.Contains("p2") Then
SectionId = ":In"
Else
If oWPname.Contains("outlet") Then
SectionId = ":Out"
Else
SectionId = ":" & Split(UCase(oWPname), ":")(1)
End If
End If
 
For Each oOcc In oOccs
 
oOccDef = oAsmCompDef.Occurrences.ItemByName(oOcc.Name).Definition
 
Try
If oWPname.Contains(":") Then
If LCase(oOcc.Name.ToString).Contains(Split(oWPname, ":")(1)) Then
If LCase(oOcc.Name).Contains("section") Then oWPname = Split(oWPname, ":")(0)
End If
End If
Catch
End Try
 
For Each oWP In oOccDef.WorkPoints
If LCase(oWP.Name) = oWPname Then
Try 
oOcc.CreateGeometryProxy(oOccDef.WorkPoints(oWP.Name), oWPProxy)
oMatrix.SetToRotation(AxisRotation, oTG.CreateVector(Xaxis, Yaxis, Zaxis), oTG.CreatePoint(0, 0, 0))
oMatrix.SetTranslation(oTG.CreateVector(oWPProxy.Point.X, oWPProxy.Point.Y, oWPProxy.Point.Z))
oOcc = oAsmCompDef.Occurrences.Add(oFullFileName, oMatrix)
oOcc.Name = oOccName1 & LCase(oWPname) & SectionId
oOcc.Grounded = True 
Exit Sub
Catch
Exit Sub
End Try
End If
Next
Next
 
End Sub
 
Sub CleanUpAssy()
Trace.TraceInformation("Start Sub CleanUpAssy")
 
' Remove all existing parts in the assembly:
Dim oOccurrence As ComponentOccurrence
Dim oComps As ComponentOccurrences
oComps = ThisDoc.Document.ComponentDefinition.Occurrences
For Each oOccurrence In oComps
Try
oOccurrence.Delete
Catch
End Try
Next
 
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisDoc.Document
 
Dim oAssyCompDef As AssemblyComponentDefinition
oAssyCompDef = oAssyDoc.ComponentDefinition
 
For Each WP In oAssyCompDef.WorkPoints
Try
WP.Delete
Catch
End Try
Next
 
RuleParametersOutput()
 
Trace.TraceInformation("End Sub CleanUpAssy")
End Sub
 
Sub DrawingParameters()
Trace.TraceInformation("Sub DrawingParameters Start")
 
Dim oAsmCompDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim oOccs As ComponentOccurrencesEnumerator = oAsmCompDef.Occurrences.AllLeafOccurrences
Dim oOcc As ComponentOccurrence
Dim oTG As TransientGeometry = ThisServer.TransientGeometry
Dim oWP As WorkPoint
 
Dim oWPProxy, LeftPointProxy, RightPointProxy, FrontPointProxy, BackPointProxy, TopPointProxy, BottomPointProxy As WorkPointProxy
Dim LeftPoint, RightPoint, FrontPoint, BackPoint, TopPoint, BottomPoint As Decimal 
 
LeftPoint = 0
RightPoint = 0
FrontPoint = 0
BackPoint = 0
TopPoint = 0
BottomPoint = 0
 
For Each oOcc In oOccs
oOccDef = oAsmCompDef.Occurrences.ItemByName(oOcc.Name).Definition
For Each oWP In oOccDef.WorkPoints
oOcc.CreateGeometryProxy(oWP, oWPProxy)
Select oWPProxy.Name
Case "Center Point"
'Center Point is not copy to drawing
Case "P2010_A", "P2010_B", "P2040"
' WorkPoints for inlet is not copy to drawing
Case "Left"
If oWPProxy.Point.X < 0 Then
If oWPProxy.Point.X <= LeftPoint Then
LeftPointProxy = oWPProxy
LeftPoint = oWPProxy.Point.X 
End If
End If 
Case "Right"
If oWPProxy.Point.X >= 0 Then
If oWPProxy.Point.X >= RightPoint Then
RightPointProxy = oWPProxy
RightPoint = oWPProxy.Point.X 
End If
End If
Case "Front"
If oWPProxy.Point.Y < 0 Then
If oWPProxy.Point.Y <= FrontPoint Then
FrontPointProxy = oWPProxy
FrontPoint = oWPProxy.Point.Y 
End If
End If
Case "Back"
If oWPProxy.Point.Y > 0 Then
If oWPProxy.Point.Y >= BackPoint Then
BackPointProxy = oWPProxy
BackPoint = oWPProxy.Point.Y 
End If 
End If
Case "Top"
If oWPProxy.Point.Z > 0 Then
If oWPProxy.Point.Z >= TopPoint Then
TopPointProxy = oWPProxy
TopPoint = oWPProxy.Point.Z
End If
End If
Case "Bottom"
If oWPProxy.Point.Z < 0 Then
If oWPProxy.Point.Z <= BottomPoint Then
BottomPointProxy = oWPProxy
BottomPoint = oWPProxy.Point.Z
End If
End If
Case "PlugWP"
'Left Point
If oWPProxy.Point.X < 0 Then
If oWPProxy.Point.X <= LeftPoint Then
LeftPointProxy = oWPProxy
LeftPoint = oWPProxy.Point.X 
End If
End If 
'Right Point
If oWPProxy.Point.X >= 0 Then
If oWPProxy.Point.X >= RightPoint Then
RightPointProxy = oWPProxy
RightPoint = oWPProxy.Point.X 
End If
End If
'Front Point
If oWPProxy.Point.Y < 0 Then
If oWPProxy.Point.Y <= FrontPoint Then
FrontPointProxy = oWPProxy
FrontPoint = oWPProxy.Point.Y 
End If
End If
'Back Point
If oWPProxy.Point.Y > 0 Then
If oWPProxy.Point.Y >= BackPoint Then
BackPointProxy = oWPProxy
BackPoint = oWPProxy.Point.Y 
End If 
End If
'Top Point
If oWPProxy.Point.Z > 0 Then
If oWPProxy.Point.Z >= TopPoint Then
TopPointProxy = oWPProxy
TopPoint = oWPProxy.Point.Z
End If
End If
'Bottom Point
If oWPProxy.Point.Z < 0 Then
If oWPProxy.Point.Z <= BottomPoint Then
BottomPointProxy = oWPProxy
BottomPoint = oWPProxy.Point.Z
End If
End If
Case Else
ValveSectionType = Split(LCase(oOcc.Name), ":")(1)
Select ValveSectionType
Case "in", "out"
NewPointName = oWPProxy.Name
Case Else
NewPointName = oWPProxy.Name & "_" & UCase(ValveSectionType)
End Select
 
oNewWorkPoint = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(oWPProxy.Point.X, oWPProxy.Point.Y, oWPProxy.Point.Z))
oNewWorkPoint.Name = NewPointName
oNewWorkPoint.Grounded = True
End Select
Next
Next
 
Try
oWP = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(LeftPointProxy.Point.X, LeftPointProxy.Point.Y, LeftPointProxy.Point.Z))
oWP.Name = "Left"
oWP.Grounded = True
Catch
End Try
Try
oWP = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(RightPointProxy.Point.X, RightPointProxy.Point.Y, RightPointProxy.Point.Z))
oWP.Name = "Right"
oWP.Grounded = True
Catch
End Try
Try
oWP = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(FrontPointProxy.Point.X, FrontPointProxy.Point.Y, FrontPointProxy.Point.Z))
oWP.Name = "Front"
oWP.Grounded = True
Catch
End Try
Try
oWP = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(BackPointProxy.Point.X, BackPointProxy.Point.Y, BackPointProxy.Point.Z))
oWP.Name = "Back"
oWP.Grounded = True
Catch
End Try
Try
oWP = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(TopPointProxy.Point.X, TopPointProxy.Point.Y, TopPointProxy.Point.Z))
oWP.Name = "Top"
oWP.Grounded = True
Catch
End Try
Try
oWP = oAsmCompDef.WorkPoints.AddFixed(oTG.CreatePoint(BottomPointProxy.Point.X, BottomPointProxy.Point.Y, BottomPointProxy.Point.Z))
oWP.Name = "Bottom"
oWP.Grounded = True
Catch
End Try
 
Trace.TraceInformation("Sub DrawingParameters End")
End Sub
 
Sub CreateSimplifiedPart()
Trace.TraceInformation("Start Sub CreateSimplifiedPart")
' Set a reference to the active assembly document
Dim oDoc As AssemblyDocument
oDoc = ThisDoc.Document
 
Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition
 
' Create a new part document that will derive the assembly
Dim oPartDoc As PartDocument
oPartDoc = ThisServer.Documents.Add(kPartDocumentObject,ThisDoc.Path() & "\Parts\SimplifiedPart.ipt" , True)
 
Dim oPartDef As PartComponentDefinition
oPartDef = oPartDoc.ComponentDefinition
 
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
oDerivedAssemblyDef = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(oDoc.FullDocumentName)
 
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = kDerivedIncludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = kDerivedIncludeAll
 
oDerivedAssemblyDef.DeriveStyle = kDeriveAsSingleBodyWithSeams 'kDeriveAsMultipleBodies
 
' Create the shrinkwrap component
Dim oDerivedAssembly As DerivedAssemblyComponent
oDerivedAssembly = oPartDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
oDerivedAssembly.BreakLinkToFile()
 
 
'DocumentTypeEnum.kAssemblyDocumentObjects
iLogicVb.UpdateWhenDone = True
Dim oAsm As AssemblyDocument = ThisDoc.Document
For Each oDocument As Document In oAsm.AllReferencedDocuments
If oDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox(oDocument.DisplayName)
End If
Next
 
'save the new part file
'(ThisDoc.Path())
Call oPartDoc.SaveAs(ThisDoc.Path() & "\generated.ipt", False)
 
' Dim partName = ThisDoc.Path() & "\" & Parameter("ForgeName") & ".ipt"
' Call oPartDoc.SaveAs(partName, False)
Trace.TraceInformation("End Sub CreateSimplifiedPart")
End Sub

 

0 REPLIES 0

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report