REMOVE CONSTRAINTS FROM SKETCH

REMOVE CONSTRAINTS FROM SKETCH

tmathieson
Advocate Advocate
711 Views
1 Reply
Message 1 of 2

REMOVE CONSTRAINTS FROM SKETCH

tmathieson
Advocate
Advocate

Good Day All.  i am having an issue with deleting constraints from a sketch.  we have a bunch of parts that have a sketch projected to them from another part in the assembly.  this is working fine, except it is slow due to  the linking to the source part.  so i am working on a rule to delete them.  however, they do not show up as geometricConstraints in the part file

 

 

Dim act_doc As PartDocument
act_doc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
 oDef = act_doc.ComponentDefinition
Dim cut_sketch As PlanarSketch
Try
	cut_sketch = oDef.Sketches.Item("BEVEL_CUT")
	LOGGER.Debug("FOUND SKETCH")
Catch EX As Exception
	Logger.Debug("NO SKETCH")
End Try
Logger.Debug(cut_sketch.GeometricConstraints.Count)
Dim ON_EDGE As GeometricConstraint
For Each ON_EDGE In cut_sketch.GeometricConstraints
	Logger.Debug(ON_EDGE.Type)

Next

.  when i run the rule as shown below, it tells me there are 0 constraints.  if i add other entities/constraints to the sketch and run the rule, it gives me a proper count so I'm pretty sure the rule is OK.  what i find interesting is that if I hit F8,  the Glyphs show on the screen, so it seems like they are some type of constraint, but not a Geometric Constraint? i only see dimensional constraints and geometric constraints for a sketch so i'm not sure where to go....

i've attached a sample part file.....

 

thanks in advance for looking, and of course for any insight or help!!

0 Likes
Accepted solutions (1)
712 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor
Accepted solution

Hi @tmathieson.  Check out SketchLine.Reference property (Read/Write Boolean, but can only change True to False), SketchLine.ReferenceComponent, and SketchLine.ReferenceEntity.  When the geometry was created by projection from another external object, it is driven by that other object, not just 'grounded', because if the source geometry moves, the projected geometry will move (unless something is wrong).

Edit:  Also look at PlanarSketch.ProjectedCuts, because the ProjectedCut object has some methods along those lines (BreakLink & Delete).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)