Get referenced entityname of sketch entity API

LS,

I'm working on a macro that selects sketchsegments based on the name of the referenced entity (all segments are converted from a 3d model into a 2d drawing). But I just can't get the relations properly. Can anyone help??

Thanx

I'm using this code:

Dim swApp As SldWorks.SldWorks Dim model As SldWorks.ModelDoc2 Dim swsketch As SldWorks.sketch Dim swsketchseg As SldWorks.SketchSegment Dim swsketch_relman As SldWorks.SketchRelationManager Dim swsketch_rel As SldWorks.SketchRelation Dim draw As SldWorks.DrawingDoc

Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object

Sub main()

Set swApp = Application.SldWorks Set model = swApp.ActiveDoc

Set swsketch = model.GetActiveSketch2

If Not swsketch Is Nothing Then

Set swsketch_relman = swsketch.RelationManager

vswsketchseg = swsketch.GetSketchSegments

For sketchsegcount_drw = 0 To UBound(vswsketchseg) Set swsketchseg = vswsketchseg(sketchsegcount_drw)

swsketchseg.Select (True) swsketchseg_relcount = swsketchseg.GetRelationsCount swsketchrels = swsketchseg.GetRelations Set swsketch_rel = swsketchrels

DefEnt_arr = swsketch_rel.GetDefinitionEntities Next sketchsegcount_drw End If End Sub

Reply to
jjzwaard
Loading thread data ...

Could your describe your goal in a little more detail?

Reply to
That70sTick

Lines from a sketch in a 3d model have to be converted in the 2d drawing. A prefix in the sketchname determines the linetype that has to be used. After converting the line in the 2d drawing, SW automatically clears the selection, which means that I have to get the entity again. The easiest way to do this is by first converting all sketch entities (from different sketches) from the sketch in the 3d model to the 2d drawing and afterwards select all sketchsegments that have an external reference to a sketch with a certain prefix.

Basicly I want to select all sketchsegments that have a relation to the same sketch.

I already have got a solution , but that's taking more time and more programming. This would be the easiest and more reliable.

Reply to
jjzwaard

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.