Hide Table of Contents

Get Entities Attached to Cosmetic Thread Example (VBA)

This example shows how to locate all cosmetic thread annotations in the drawing view, obtain the associated entities, and query those entities for their radius values. It is assumed that you have a drawing view selected.

 

'---------------------------------------------

Private Sub Command3_Click()

Dim swApp As Object

Dim activeDocument As Object

Dim pAnnotation As Object

Dim selType As Long

Dim entityCount As Long

Dim SelMgr As Object

Dim entitiesArray As Variant

Dim attachedEntity As Object

Dim selView As Object

 

Const swDocDRAWING = 3

Const swSelEDGES = 1

Const swSelFACES = 2

Const swSelCTHREADS = 39

Const swSelDRAWINGVIEWS = 12

Const swCThread = 1

 

Set swApp = CreateObject("SldWorks.Application")

Set activeDocument = swApp.ActiveDoc

 

If (activeDocument.GetType <> swDocDRAWING) Then

Exit Sub

End If

 

Set SelMgr = activeDocument.SelectionManager

 

selType = SelMgr.GetSelectedObjectType2(1)

 

If (selType = swSelDRAWINGVIEWS) Then

' Get the selected drawing view

Set selView = SelMgr.GetSelectedObject5(1)

If (selView Is Nothing) Then

Exit Sub

End If

 

' Get first annotation in the view

Set pAnnotation = selView.GetFirstAnnotation3

 

' Loop through every annotation in view

While (Not pAnnotation Is Nothing)

' Get the type of annotation

annotType = pAnnotation.GetType

' For each CThread, get radius of attached entity

If (annotType = swCThread) Then

 

' Get attached entities

entitiesArray = pAnnotation.GetAttachedEntities

attachedEntityTypes = pAnnotation.GetAttachedEntityTypes 

' Get number of attached entities

entityCount = UBound(entitiesArray) + 1

' For each entity attached to this CThread

For i = 0 To (entityCount - 1) 

' Get the individual Edge or Face object

Set attachedEntity = entitiesArray(i)

 

' If attached entity is an edge

If (attachedEntityTypes(i) = swSelEDGES) Then

edgeParams = attachedEntity.GetCurve.CircleParams

edgeRadius = edgeParams(6)

swApp.SendMsgToUser "Cosmetic Thread Edge Radius = " + Str(edgeRadius)

 

' If attached entity is an face

ElseIf (attachedEntityTypes(i) = swSelFACES) Then

faceParams = attachedEntity.GetSurface.CylinderParams

faceRadius = faceParams(6)

swApp.SendMsgToUser "Cosmetic Thread Face Radius = " + Str(faceRadius)

End If

Next i

 

' End if this annotation is a cosmetic thread (CThread)

End If

Set pAnnotation = pAnnotation.GetNext3

 

' End while annotations exist in the selected drawing view

Wend

Else

swApp.SendMsgToUser "Please select a drawing view containing cosmetic thread annotations"

 

End If

 

End Sub

 

 



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Entities Attached to Cosmetic Thread Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2012 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.