Weld assembly with attributes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am working on automating some drawings. For a weld assembly, I use machining to adjust certain features because my step always varies. Using nifty attributes, I created two attributes: one for left (left = l) and one for right (right = r). I can find these when I search for the attributes in the weld assembly.
However, when I try to find these attributes in the .dwg, I can't locate them, so I'm unable to add dimensions. Does anyone have a solution for creating a drawing with a weld assembly, or should I take a different approach? If it’s a part, I can use the “assign entity name” option.
This is the code I want to use bur everytime i got the message "Not all faces found!" , I found it through the following link:
https://www.youtube.com/watch?v=bcOvYc6rNUk
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oView As DrawingView
oView = oSheet.DrawingViews.Item(1)
' Reference to the assembly in the view
Dim oAssembly As AssemblyDocument
oAssembly = oView.ReferencedDocumentDescriptor.ReferencedDocument
' Reference to the GeneralDimensions on the drawing
Dim oGeneralDims As GeneralDimensions
oGeneralDims = oSheet.DrawingDimensions.GeneralDimensions
' Declare Face1 and Face2 outside the loop
Dim Face1 As Face = Nothing
Dim Face2 As Face = Nothing
' Iterate over all referenced documents within the assembly
Dim oModelDoc As Document
Dim oObjs As ObjectsEnumerator
For i = 1 To oAssembly.ReferencedDocuments.Count
oModelDoc = oAssembly.ReferencedDocuments.Item(i)
' Find Face1 and Face2 via attributes
oObjs = oModelDoc.AttributeManager.FindObjects("*", "*", "L")
If oObjs.Count > 0 Then Face1 = TryCast(oObjs.Item(1), Face)
oObjs = oModelDoc.AttributeManager.FindObjects("*", "*", "R")
If oObjs.Count > 0 Then Face2 = TryCast(oObjs.Item(1), Face)
' Check if both Faces are found
If Face1 Is Nothing Or Face2 Is Nothing Then
MessageBox.Show("Not all faces found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Return
End If
Next
' Iterate over the components in the assembly
Dim oCompOcc As ComponentOccurrence
Dim oOccFace1Proxy As FaceProxy
Dim oOccFace2Proxy As FaceProxy
For Each oCompOcc In oAssembly.ComponentDefinition.Occurrences
' Create GeometryProxies for the Faces
oCompOcc.CreateGeometryProxy(Face1, oOccFace1Proxy)
oCompOcc.CreateGeometryProxy(Face2, oOccFace2Proxy)
' Get the corresponding drawing curves
Dim oDrawCurves1 As DrawingCurve
Dim oDrawCurves2 As DrawingCurve
oDrawCurves1 = oView.DrawingCurves(oOccFace1Proxy).Item(1)
oDrawCurves2 = oView.DrawingCurves(oOccFace2Proxy).Item(1)
' Create GeometryIntents for the dimension
Dim GI1 As GeometryIntent
Dim GI2 As GeometryIntent
GI1 = oSheet.CreateGeometryIntent(oDrawCurves1)
GI2 = oSheet.CreateGeometryIntent(oDrawCurves2)
' Determine the position for the dimension
Dim TextPoint As Point2d
Dim Xpos As Double
Dim Ypos As Double
Xpos = 10
Ypos = oView.Top + 1
TextPoint = ThisApplication.TransientGeometry.CreatePoint2d(Xpos, Ypos)
' Add the dimension
Dim oDim1 As GeneralDimension
oDim1 = oGeneralDims.AddLinear(TextPoint, GI1, GI2)
Next