Hi,
I'm trying to add on drawing this anotation on every thread (only thread)

My code for selected all cercle but i'm trying to finish the add anotation
Option Explicit Dim swApp <span class="">As</span> SldWorks.SldWorks Dim swModel <span class="">As</span> SldWorks.ModelDoc2 Dim swDraw <span class="">As</span> SldWorks.DrawingDoc Dim swView <span class="">As</span> SldWorks.View Dim Comp <span class="">As</span> SldWorks.Component2 Dim vComps <span class="">As</span> Variant Dim vComp <span class="">As</span> Variant Dim vEdges <span class="">As</span> Variant Dim vEdge <span class="">As</span> Variant Dim swEdge <span class="">As</span> SldWorks.Edge Dim swCurve <span class="">As</span> SldWorks.Curve Dim swEntity <span class="">As</span> SldWorks.Entity Dim CurveParam <span class="">As</span> Variant Dim IsClosed <span class="">As</span> Boolean Dim Diameter <span class="">As</span> Double Dim boolstatus <span class="">As</span> Boolean Sub main() Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDraw = swModel Set swView = swDraw.ActiveDrawingView swModel.ClearSelection2 <span class="">True</span> vComps = swView.GetVisibleComponents <span class="">'Diameter = InputBox("Entrer le diamètre en mm") For Each vComp In vComps Set Comp = vComp vEdges = swView.GetVisibleEntities(Comp, swViewEntityType_e.swViewEntityType_Edge) For Each vEdge In vEdges Set swEdge = vEdge Set swCurve = swEdge.GetCurve If swCurve.IsCircle Then swCurve.GetEndParams Empty, Empty, IsClosed, Empty If IsClosed Then CurveParam = swCurve.CircleParams '</span><span class="">If</span> Abs(Diameter - CurveParam(<span class="">6</span>) * <span class="">2</span> * <span class="">1000</span>) < <span class="">0.0001</span> Then Set swEntity = swEdge swEntity.Select4 <span class="">True</span>, Nothing <span class="">'ici le code pour cotation avec hole callout '</span>End <span class="">If</span> End <span class="">If</span> End <span class="">If</span> Next Next <span class="">'swModel.SetLineColor 255 swModel.ClearSelection2 True End Sub</span>Thanks
Sébastien
SolidworksApi/macros
Please see below for updated code
I don't get the question but I thought this would be helpful to someone who can give an answer.
Thanks & Regards
Prashant Baher
If you change hole callouts, you will need an addin to maintain them as solidworks will constantly overwrite the call-out text you provide. Trust me. It's not something you want to battle against.
When a view is clicked solidworks will update the call-out, when a callout is moved, sometimes solidworks will overwrite your callout.
It's not so fun to deal with.
Hi,
I am sorry I don't understand "Balise" !!!
But I can show you how I paste code and format them in this forum.
Please see below GIF file.
This is just demo code.
I hope this will help you.
Thanks & Regards
Prashant Baher
That's works but i dont want this:
"Trou Taraudé M10" but only "M10"
Is this possible without modifying the file: calloutformat.txt
for my part I tried this code but impossible to limit the anotation only to the treads:
Dim Annotations As Variant
Annotations = SwDraw.InsertModelAnnotations3(0, swInsertAnnotation_e.swInsertholeCallout, True, False, False, False)
I try this monday, today it's not possible Thanks
How to Ctr+V with balise for code please?
Instead of finding circular edges in the model, you need to find Cosmetic Threads in the drawing view.
Try this:
Dim vThreads As Variant
Dim vThread As Variant
Dim swThread As CThread
Dim swAnn As Annotation
Dim swDrawingComp As DrawingComponent
vThreads = swView.GetCThreads
If Not IsEmpty(vThreads) Then
For Each vThread In vThreads
Set swThread = vThread
Set swAnn = swThread.GetAnnotation
Set swDrawingComp = swView.RootDrawingComponent
boolstatus = swModel.Extension.SelectByID2(swAnn.GetName & "@" & swDrawingComp.Name & "@" & swView.Name, "CTHREAD", 0, 0, 0, False, 0, Nothing, 0)
swDraw.InsertThreadCallout
Next
End If