I have a drawing with a view that contains a break out. I need to automate the location and size of the breakout profile as the subject of the breakout moves from one configuration or to another. Also, I cannot constrain the profile because the subject of the breakout is suppressed in some configurations.
I have a rule that is successfully able to adjust the size of the profile but I have had no luck with adjusting the location.
My hope is to be able to set the center of the ellipse as seen below in relation to the center of the detail view.
As a test, I can read the values of:
oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.X
oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.Y
But when setting them, there is no error but no effect either. Any thoughts on how to modify the center of this ellipse?
If oView.Name = "2" If access_port_quantity <> 0 Then oView.Suppressed = False '[Resizes breakout profile oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.X = 10 oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.Y = 10 oView.Sketches.Item(1).DimensionConstraints.Item(1).Parameter.Value = access_height * 2.54 oView.Sketches.Item(1).DimensionConstraints.Item(2).Parameter.Value = access_width * 2.54 '] '[Get object for reassociating break out view Dim oReferencedDocument As Document oReferencedDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument If oReferencedDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then For Each oComponent As ComponentOccurrence In oReferencedDocument.ComponentDefinition.Occurrences If oComponent.Name = "_Access Port Cover" Then oView.BreakOutOperations.Item(1).SetDepth(oComponent) End If Next End If '] Else oView.Suppressed = True End If End If
Solved! Go to Solution.
I have a drawing with a view that contains a break out. I need to automate the location and size of the breakout profile as the subject of the breakout moves from one configuration or to another. Also, I cannot constrain the profile because the subject of the breakout is suppressed in some configurations.
I have a rule that is successfully able to adjust the size of the profile but I have had no luck with adjusting the location.
My hope is to be able to set the center of the ellipse as seen below in relation to the center of the detail view.
As a test, I can read the values of:
oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.X
oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.Y
But when setting them, there is no error but no effect either. Any thoughts on how to modify the center of this ellipse?
If oView.Name = "2" If access_port_quantity <> 0 Then oView.Suppressed = False '[Resizes breakout profile oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.X = 10 oView.Sketches.Item(1).SketchEllipses.Item(1).Geometry.Center.Y = 10 oView.Sketches.Item(1).DimensionConstraints.Item(1).Parameter.Value = access_height * 2.54 oView.Sketches.Item(1).DimensionConstraints.Item(2).Parameter.Value = access_width * 2.54 '] '[Get object for reassociating break out view Dim oReferencedDocument As Document oReferencedDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument If oReferencedDocument.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then For Each oComponent As ComponentOccurrence In oReferencedDocument.ComponentDefinition.Occurrences If oComponent.Name = "_Access Port Cover" Then oView.BreakOutOperations.Item(1).SetDepth(oComponent) End If Next End If '] Else oView.Suppressed = True End If End If
Solved! Go to Solution.
Solved by J_Pfeifer_. Go to Solution.
The way I managed to move sketches for details or so on depends on the sketch itself but always was the result of moving the point 2d object. Let me clarify, If you create a sketch on the drawing view such as Dim oDrawingSketch as DrawingSketch = oView.sketches.add() The placement of the CenterPoint that sketch will start and scale differently than a drawing view made on the drawing or document: Dim oSheetView as DrawingSketch = Sheet.sketches.add().
When you're working with a sketch placed on a drawing view specifically, the start location (0, 0) will be the bottom left of that view on the drawing. Then moving that point or it's creation location. The movement must be scaled to the model, or that is to say the movement of the point object is subject to the that items cartesian coordinate system.
On the flip side, when you're working inside a sketch on a sheet. The starting location (0, 0) will be the bottom left of the sheet itself. Then the point object that's moving to change the location will be affected by the 11 x 17 or whatever the sheet size is, or the cartesian coordinate system of the drawing.
Depending on what object you're working with, moving the point2d object that controls the center location of the ellipse will have different math or different items you can reference. I typically use the sheet drawing sketch unless it's a section that requires a drawing view sketch. This way I can control the location of the breakout depending on the location of my views. This may differ in other situations where views may not be as static as our system.
The way I managed to move sketches for details or so on depends on the sketch itself but always was the result of moving the point 2d object. Let me clarify, If you create a sketch on the drawing view such as Dim oDrawingSketch as DrawingSketch = oView.sketches.add() The placement of the CenterPoint that sketch will start and scale differently than a drawing view made on the drawing or document: Dim oSheetView as DrawingSketch = Sheet.sketches.add().
When you're working with a sketch placed on a drawing view specifically, the start location (0, 0) will be the bottom left of that view on the drawing. Then moving that point or it's creation location. The movement must be scaled to the model, or that is to say the movement of the point object is subject to the that items cartesian coordinate system.
On the flip side, when you're working inside a sketch on a sheet. The starting location (0, 0) will be the bottom left of the sheet itself. Then the point object that's moving to change the location will be affected by the 11 x 17 or whatever the sheet size is, or the cartesian coordinate system of the drawing.
Depending on what object you're working with, moving the point2d object that controls the center location of the ellipse will have different math or different items you can reference. I typically use the sheet drawing sketch unless it's a section that requires a drawing view sketch. This way I can control the location of the breakout depending on the location of my views. This may differ in other situations where views may not be as static as our system.
I wrote a little something something up for you. I forgot a critical component to this function. You need to activate the sketch edit before attempting to create the sketch objects. The Point 2d is outside of this sketch, it can be created whenever, but we must actively be in the sketch to start placing sketch entities.
Run the following code, and you can see how you go about moving the objects around. This is just a funny way to "animate" its movement across the sheet.
Sub main()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
Dim oSketch As DrawingSketch = oSheet.Sketches.Add()
Dim oPoint2d As Point2d = oTG.CreatePoint2d(5, 5)
oSketch.Edit
Dim oSketchPoint As SketchPoint = oSketch.SketchPoints.Add(oPoint2d)
Dim oSketchCircle As SketchCircle = oSketch.SketchCircles.AddByCenterRadius(oSketchPoint, 10 * 2.54)
'add the constraints to the circle.
Dim SketchCirCon As GeometricConstraint = oSketch.GeometricConstraints.AddCoincident(oSketchCircle.CenterSketchPoint, oSketchPoint)
Dim SketchCirDia As DimensionConstraint = oSketch.DimensionConstraints.AddDiameter(oSketchCircle, oTG.CreatePoint2d(15, 15))
Dim IterationIndex As Integer = 0
Dim NumberOfOperations As Integer = 10
While IterationIndex <= NumberOfOperations
oPoint2d.X = oPoint2d.X + 2
oPoint2d.Y = oPoint2d.Y + 2
oSketchPoint.MoveTo(oPoint2d)
IterationIndex = IterationIndex + 1
Logger.Info("Iteration: " & IterationIndex)
oDoc.Update
End While
oSketch.ExitEdit
End Sub
A good example of the size stuff I explained before is the size of this circle. It's created as a 10" diameter circle on the sheet, leading to a very large circle. Do the same size circle on the view object, and that circle could be larger or smaller depending on that parts overall size.
I wrote a little something something up for you. I forgot a critical component to this function. You need to activate the sketch edit before attempting to create the sketch objects. The Point 2d is outside of this sketch, it can be created whenever, but we must actively be in the sketch to start placing sketch entities.
Run the following code, and you can see how you go about moving the objects around. This is just a funny way to "animate" its movement across the sheet.
Sub main()
Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oSheet As Sheet = oDoc.Sheets.Item(1)
Dim oSketch As DrawingSketch = oSheet.Sketches.Add()
Dim oPoint2d As Point2d = oTG.CreatePoint2d(5, 5)
oSketch.Edit
Dim oSketchPoint As SketchPoint = oSketch.SketchPoints.Add(oPoint2d)
Dim oSketchCircle As SketchCircle = oSketch.SketchCircles.AddByCenterRadius(oSketchPoint, 10 * 2.54)
'add the constraints to the circle.
Dim SketchCirCon As GeometricConstraint = oSketch.GeometricConstraints.AddCoincident(oSketchCircle.CenterSketchPoint, oSketchPoint)
Dim SketchCirDia As DimensionConstraint = oSketch.DimensionConstraints.AddDiameter(oSketchCircle, oTG.CreatePoint2d(15, 15))
Dim IterationIndex As Integer = 0
Dim NumberOfOperations As Integer = 10
While IterationIndex <= NumberOfOperations
oPoint2d.X = oPoint2d.X + 2
oPoint2d.Y = oPoint2d.Y + 2
oSketchPoint.MoveTo(oPoint2d)
IterationIndex = IterationIndex + 1
Logger.Info("Iteration: " & IterationIndex)
oDoc.Update
End While
oSketch.ExitEdit
End Sub
A good example of the size stuff I explained before is the size of this circle. It's created as a 10" diameter circle on the sheet, leading to a very large circle. Do the same size circle on the view object, and that circle could be larger or smaller depending on that parts overall size.
Thank you for this information. Activating the sketch was the missing piece of the puzzle that I needed.
Thank you for this information. Activating the sketch was the missing piece of the puzzle that I needed.
Can't find what you're looking for? Ask the community or share your knowledge.