- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi guys,
I am automating a drawing. In this particular code I am adding a linear dimension to a part in an assembly.
I am selecting a face which in the oSideView is only visible as a line:
The green marked part of the face is one of the curve candidates.
Here is the code:
oCompOcc1 = oAssDoc.ComponentDefinition.Occurrences.ItemByName("MyPart")
oPartDoc = oCompOcc1.Definition.Document
myNamedEntities1 = iLogicVb.Automation.GetNamedEntities(oPartDoc)
oCompOcc2 = oAssDoc.ComponentDefinition.Occurrences.ItemByName("MyPart")
oPartDoc = oCompOcc2.Definition.Document
myNamedEntities2 = iLogicVb.Automation.GetNamedEntities(oPartDoc)
oFace1 = myNamedEntities1.FindEntity("Vorderseite_rechts")
oFace2 = myNamedEntities2.FindEntity("Vorderseite_links")
Call oCompOcc1.CreateGeometryProxy(oFace1, oFace1Proxy)
Call oCompOcc2.CreateGeometryProxy(oFace2, oFace2Proxy)
myCurveCandidates = oSideView.DrawingCurves(oFace1Proxy)
myCurveCandidates2 = oSideView.DrawingCurves(oFace2Proxy)
Logger.Debug("MyCurveCandidates1 " & myCurveCandidates.Count)
Logger.Debug("MyCurveCandidates2 " & myCurveCandidates2.Count)
ExitFlag = False
For i = 1 To myCurveCandidates.Count
For j = 1 To myCurveCandidates2.Count
myDrawingCurve1 = myCurveCandidates.Item(i)
oGeoIntent1 = oSheet.CreateGeometryIntent(myDrawingCurve1)
myDrawingCurve2 = myCurveCandidates2.Item(j)
oGeoIntent2 = oSheet.CreateGeometryIntent(myDrawingCurve2)
Logger.Debug("i = " & i & " , X = " & myDrawingCurve1.StartPoint.X)
Logger.Debug("j = " & j & " , X = " & myDrawingCurve2.StartPoint.X)
myPos2d = oTG.CreatePoint2d(myDrawingCurve1.StartPoint.X / 2 + myDrawingCurve2.StartPoint.X / 2, oSideView.Top + 3.5)
Try
oSheet.DrawingDimensions.GeneralDimensions.AddLinear(myPos2d, oGeoIntent1, oGeoIntent2)
ExitFlag = True
Exit For
Catch
'nothing
End Try
Next
If ExitFlag Then
Exit For
End If
Next
Here is my debugger output:
DEBUG|MyCurveCandidates1 7
DEBUG|MyCurveCandidates2 7
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 1 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 2 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 3 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 4 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 5 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 6 , X = 18,395833333325
DEBUG|i = 1 , X = 37,504166666675
DEBUG|j = 7 , X = 18,395833333325
DEBUG|i = 2 , X = 37,504166666675
DEBUG|j = 1 , X = 18,395833333325
DEBUG|i = 2 , X = 37,504166666675
DEBUG|j = 2 , X = 18,395833333325
The code above works fine and as you can see once curve candidates 2 and 2 are seleceted the linear dimension is added.
Here are my questions:
1) Why does this problem exist in the first place? What is wrong with the curce candidate with index 1? In other parts candidates 1 and 2 wont work and I have to select 3, which is why I am doing the loop.
2) The Try-Catch is not best practice but just something that works for now. Any idea how I can test the curve candidates for specific properties rather than just trying to add the dimenion and if it fails try with another candidate?
Thanks
Jonas
Solved! Go to Solution.