- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, the problem that I face is to have an automated Assembly Drawings for the master assembly that I made in which there are a lot of configurations for it. (bag filter)
Dimensions that specifying -for example- the stiffeners spacing is deleted when I configure the master assembly to a different one.
I used the attribute to name the edges of a part in the assembly and I have written a code to add the dimension that I need on the assembly Drawing, the code works fine but I need to modify it so instead of specifying the number of the wanted item " item(1) for example" I would like to input the name of the item and the code search and return the item number, this because when I configure the master assembly, the number of the wanted item is changed and its occurrence item number is also changed.
Sub CreatAssemblyDim() ' refer to the file Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument 'refer to the active sheet Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet 'refer to the view Dim oView As DrawingView Set oView = oSheet.DrawingViews.Item(1) 'refer to the assembly on the view Dim oAssembly As AssemblyDocument Set oAssembly = oView.ReferencedDocumentDescriptor.ReferencedDocument 'find the model referenced in the assembly 'Dim i As Integer 'For i = 1 To oAssembly.ReferencedDocuments.Count Dim oModelDoc As Document Set oModelDoc = oAssembly.ReferencedDocuments.Item(2) ' refer to the edge Dim Edge1 As Edge 'MsgBox (oModelDoc.DisplayName) Set Edge1 = oModelDoc.AttributeManager.FindObjects("*", "*", "Left").Item(1) Dim Edge2 As Edge Set Edge2 = oModelDoc.AttributeManager.FindObjects("*", "*", "Right").Item(1) 'Next ' refere to occurrence in the assembly Dim oCompOcc As ComponentOccurrence For Each occurrence In oAssembly.ComponentDefinition.Occurrences 'becouse there's only one occurrence Set oCompOcc = oAssembly.ComponentDefinition.Occurrences.Item(1) ' promote the model edge to the assembly using poroxy Dim oOccEdge1Proxy As EdgeProxy Dim oOccEdge2Proxy As EdgeProxy Call oCompOcc.CreateGeometryProxy(Edge1, oOccEdge1Proxy) Call oCompOcc.CreateGeometryProxy(Edge2, oOccEdge2Proxy) Next 'promote to an a DrawingCurve on the view Dim oDrawingCurves1 As DrawingCurve Set oDrawingCurves1 = oView.DrawingCurves(oOccEdge1Proxy).Item(1) Dim oDrawingCurves2 As DrawingCurve Set oDrawingCurves2 = oView.DrawingCurves(oOccEdge2Proxy).Item(1) 'promote to a geometryIntent on the sheet Dim GI1 As GeometryIntent Set GI1 = oSheet.CreateGeometryIntent(oDrawingCurves1) Dim GI2 As GeometryIntent Set GI2 = oSheet.CreateGeometryIntent(oDrawingCurves2) 'Create a general Dimension on that shett Dim oGeneralDims As GeneralDimensions Set oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions ' Create point for the text Dim TextPoint As Point2d Dim Xpo As Double Dim Ypo As Double Xpo = oView.Left + (oView.Width / 4) Ypo = oView.Top + 3 Set TextPoint = ThisApplication.TransientGeometry.CreatePoint2d(Xpo, Ypo) ' Create the Dimemsion Dim oDim1 As GeneralDimension Set oDim1 = oGeneralDims.AddLinear(TextPoint, GI1, GI2) For Each oDim1 In oGeneralDims If oDim1.Attached = False Then Call oDim1.Delete End If Next End Sub
Solved! Go to Solution.