symeetry constraint

symeetry constraint

diseno_cad4
Participant Participant
309 Views
4 Replies
Message 1 of 5

symeetry constraint

diseno_cad4
Participant
Participant
hello everyone

can you help me

I try to make a symmetry of some points that I have in the sketch but it generates an error




Dim
oDoc As Document oDoc = ThisApplication.ActiveDocument Dim Boceto As Sketch Boceto = oDoc.ComponentDefinition.Sketches.Item("Hole_Tubes") Dim oSymmetryLine As SketchLine Dim oSymmetry As SymmetryConstraint Dim oTransGeom As TransientGeometry oTransGeom = ThisApplication.TransientGeometry Dim oSymmetryLineX As SketchLine oSymmetryLineX = Boceto.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, -10), oTransGeom.CreatePoint2d(0, 10)) Dim sketchPoints As SketchEntitiesEnumerator sketchPoints = Boceto.SketchPoints oSymmetry = Boceto.GeometricConstraints.AddSymmetry(sketchPoints, sketchPoints, oSymmetryLineX

 

 

 

0 Likes
310 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @diseno_cad4.  In the last few lines of your code, you need to specify two different individual SketchEntity objects that the symmetry will effect.  You are attempting to provide the entire collection of sketch points as both the first and second entity in your code, which will not work.  I do not know specifically which two sketch entity objects you will need to control by symmetry, because I am not familiar with your existing sketch, so I will likely not be able to fix it exactly the way you want it, but I can help clarify it a bit for you.  In the edited example below, I am simply getting the first two SketchPoint objects from within the PlanarSketch, as the two entities that you are trying to control by symmetry.  If those are not the correct two sketch entities, then you will have to change those last 3 lines of code the way you need them.

Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

Dim Boceto As PlanarSketch
Boceto = oDoc.ComponentDefinition.Sketches.Item("Hole_Tubes")

Dim oSymmetryLine As SketchLine
Dim oSymmetry As SymmetryConstraint
Dim oTransGeom As TransientGeometry
oTransGeom = ThisApplication.TransientGeometry

Dim oSymmetryLineX As SketchLine
oSymmetryLineX = Boceto.SketchLines.AddByTwoPoints(oTransGeom.CreatePoint2d(0, -10), oTransGeom.CreatePoint2d(0, 10))

'SketchEntity is a generic term, and can represent nearly any type of sketch geometry
'first SketchEntity to control by symmetry
Dim SketchPoint1 As SketchPoint = Boceto.SketchPoints.Item(1) 'change if needed
'second SketchEntity to control by symmetry
Dim SketchPoint2 As SketchPoint = Boceto.SketchPoints.Item(2) 'change if needed

oSymmetry = Boceto.GeometricConstraints.AddSymmetry(SketchPoint1, SketchPoint2, oSymmetryLineX)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

diseno_cad4
Participant
Participant

thanks for your answer,
I need to make the symmetry of a set of points

 

diseno_cad4_0-1712676419309.png

 

I read somewhere that you have to put them in a collection to be able to grab them all.

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

Hi @diseno_cad4.  I honestly do not to a ton of sketch manipulation by code, but I do not believe there is a way to mirror a group of SketchPoints as one operation by code, and maintain the symmetry constraints.

  • We have a method for 'moving' (and optionally copying in the process) a group of sketch entities within the same sketch (PlanarSketch.MoveSketchObjects).
  • We have a method to 'rotate' (and optionally copy in the process) a group of sketch entities within the same sketch (PlanarSketch.RotateSketchObjects).
  • We have a couple methods to 'offset' a group of sketch entities within the same sketch (PlanarSketch.OffsetSketchEntitiesUsingDistance & PlanarSketch.OffsetSketchEntitiesUsingPoint).
  • We have methods for 'copying' a group of sketch entities from one sketch to another (PlanarSketch.CopyContentsTo & PlanarSketch.CopyEntitiesTo).
  • But no method for 'mirroring' a group of sketch entities within the same sketch (by code).
    • Maybe they will add a method for this in a future release of Inventor (I'm using 2024.2.1).
  • And that GeometricConstraints.AddSymmetry method is just for use on two individual sketch objects, and both of them need to be the same type of sketch object, not for whole groups of objects.
  • As it stands right now, I believe that to simulate this behavior, you would need to create each new SketchPoint, one by one, on the other side of the mirror / symmetry line, then add the symmetry constraint between the new one and the old one, if doing it by code.

Edit:  Since these are SketchPoints, and the pattern appears to be within a round face, if the pattern is also symmetrical top to bottom, then you may be able to use the 'Rotate' method I mentioned above (Link), then specify the center point, instead of a symmetry line.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

diseno_cad4
Participant
Participant

ok , thanks very much 

0 Likes