Dimensions of the room

Hello

I am trying to determine the dimensions of a room in SW, citing that I use VB.NET.

I am waiting for your help and thank you.

Hello

At one time, I had made a small utility that allowed me to do something similar, see HERE.

Kind regards

1 Like

Here is another model that, as stated, "without a Privilege subscription can be used and tested for 1 month.", see HERE.

Kind regards

1 Like

And here is a version of the utility I had made but with the addition of a button to calculate the footprint on the part or assembly already loaded in Solidworks.

Kind regards


boundingbox-4.zip
3 Likes

Hello and thank you for your help,

it's not exactly that, I'm trying to determine the length and width (or diameter) of a part in SW using the VB.NET code.

Hello

Probable error of understanding on my part, if I understand correctly then what you are trying to do is to drive VB.NET odds?

Kind regards

2 Likes

Hello

what I'm looking for exactly is the determination of the length and diameter of a screw in an assembly on SW using VB.net, to use them later.

Hello

To do this, you can use the configurations. You create your screw and for each length or diameter you make an additional configuration.

Hello

I don't really understand the final need because for screws, as ac cobra 427 says, there is the possibility to use configurations, or to use the toolbox. Now if it's to drive dimensions on a SW part, it's possible to do it as below.

If we consider that the part loaded in SW is composed of a "Boss.-Extru.1" function made from a "Sketch1" sketch in which we find the dimensions "D1@Esquisse1" and "D2@Esquisse1" for width and length and that the thickness dimension of the extrusion is called "D1@Boss.-Extru.1" then we can control them as follows:

Dim swApp As Object
Dim Part As Object
Dim myDimension As Object
Dim boolstatus As Boolean

Sub main()
    Set swApp = Application.SldWorks
    Set Part = swApp.ActiveDoc
    Set myDimension = Part.Parameter("D1@Esquisse1")
    myDimension.SystemValue = 0.11
    Set myDimension = Part.Parameter("D2@Esquisse1")
    myDimension.SystemValue = 0.05
    Set myDimension = Part.Parameter("D1@Boss.-Extru.1")
    myDimension.SystemValue = 0.002
    boolstatus = Part.ForceRebuild3(True)
    Part.ClearSelection2 True
End Sub

Kind regards

1 Like

Hello and thank you for your answer,

The problem is that I want to determine the dimensions of the standard elements added from SW libraries (screws, nuts, etc.), so I can't access their sketches.

Hello

What do you mean by standard elements added from the SW library? Can you post an example of a part for analysis?

Kind regards

Hello

An example is attached.

So, I tried this algorithm but I didn't get results:

        swModel = swApp.ActiveDoc

        swConfigMgr = swModel.ConfigurationManager

        swConfig = swConfigMgr.ActiveConfiguration
        Dim swDocExt As ModelDocExtension
        Dim boo As Boolean
        swModel.ClearSelection2(True)
        swDocExt = swModel.Extension()
        boo = swDocExt.SelectByID2("part@assembly", "COMPONENT", 0, 0, 0, True, 1, Nothing, 0)
 
        Dim strCompModelname2 As String
        strCompModelname2 = "part.sldprt"
        swModel = swApp.ActiveDoc

        swDim = swModel.Parameter(strCompModelname2)

        vConfigNameArr = swModel.GetConfigurationNames

        For Each vConfigName In vConfigNameArr

            sSpecConfigNameArr(0) = vConfigName

            vSpecConfigNameArr = sSpecConfigNameArr

            vDimValArr = swDim.GetValue3(swInConfigurationOpts_e.swSpecifyConfiguration, vSpecConfigNameArr)
            Debug.Assert(0 = UBound(vDimValArr))

            For Each vDimVal In vDimValArr

                Debug.Print("      " & vConfigName & " -->" & vDimVal)

            Next

        Next


din-933.jpg

Hello

By " Can you post an example of a part for analysis? ", I meant one of your pieces in sldprt format, not a jpeg image!!

Kind regards

1 Like

Good evening

Here is the example in .sldprt format


jaw_screw.sldprt

Hello

That's what I suspected, these are imported parts so you won't be able to find any quotations since there are none:

Kind regards

Hello

To enable sketches in an imported body you can use Featurworks which will recognize all the functions of a part...

It's a possibility but, in view of the part, I think it's better to rebuild it completely, it will have the merit of having completely constrained sketches and slightly more "intelligent" functions.

Or take a part from the Toolbox if there is an equivalent.

For the featureWorks, you must first remove the "Body-Move" move function otherwise FeatureWorks is not usable:

Kind regards

1 Like

Hello

I deleted "Body-Move", then, I clicked on featureworks - recognize the functions ...

an error message is displayed "image", then when I click on ok, the SW closes by itself.


image.png

Hello

It doesn't seem to come from your part (treatment done on SW 2017):

So see about your settings or your installation of SW (which version?)

Kind regards

1 Like

Hello

I managed to view the sketch of the parts.

The problem now is to determine the length of a selected part through its sketch. 

I'm going to show you an example of an algorithm that I tested but without any results:

1 /

    Dim vDimVal As Object
        Dim Part As ModelDoc2
        Part = swApp.ActiveDoc
Dim swDim As Dimension
        swDim = Part.Parameter("D2@Esquisse1@part1@assembly")
       vDimVal = swDim.GetSystemValue3(swInConfigurationOpts_e.swThisConfiguration, Nothing)
        vDimVal = swSelMgr.GetSelectedObject6(1, -1)
        MsgBox(vDimVal)

 

result = empty box