Secondary Development of SolidWorks-03-accessing feature data

Source: Internet
Author: User
Secondary Development of SolidWorks-03-accessing feature data

'Coder Arden
'Filename: getchoosed. SWP
'Date: 2005-03-22
'Used to get the simple hole infomation Dep & Dia
'Finished lucky !!
'------------------------------------------------------------

Option explicit
Dim swapp as sldworks. sldworks
Dim model as modeldoc2
Dim curfeature as feature
Dim boolstatus as Boolean
Dim featdata as simpleholefeaturedata2 'declares a simple direct hole object
Dim component as component2
Dim Dep as double
Dim Dia as double
Dim selmgr as selectionmgr
Dim ncount as integer

 

Sub getselected ()

Set swapp = application. sldworks

Set Model = swapp. activedoc

Set selmgr = model. selectionmanager

Set curfeature = selmgr. getselectedobject5 (1) 'to obtain the first feature selected currently.

Msgbox curfeature. Name

Set featdata = curfeature. getdefinition 'to get the feature definition.

Boolstatus = featdata. accessselections (model, component) 'can access the data

Ncount = featdata. getfeaturescopebodiescount

Msgbox ncount

Dep = featdata. Depth
Dia = featdata. Diameter

Msgbox Dia & "*" & Dep

You can use swapp. sendmsgtouser2 in SolidWorks.
'Featdata. releaseselectionaccess
Model. Save
Model. editrebuild
End sub

**************************************** ******

Before running the program, assume you have selected a simple direct hole feature. Then we can get some parameters of this AMAP.

Hole depth, diameter, etc.

SolidWorks APIs are in E. The introduction is still detailed, and there are many example. You can take a look at the code.

To access a feature, follow these steps:

Define a feature object: dim......

This feature is obtained: for example, getselectedobject5 and selectebyid...

Get the definition: getdefinition

Access: accessselections

The above program does not have the fault tolerance mechanism selected by If. You need to add it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.