Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify Fixed Relations 2

Status
Not open for further replies.

malis

Mechanical
Nov 29, 2005
31
Is it possible to quickly identify if a sketch has been constrained properly with dimensions rather than defining with a fixed relation in order to make the sketch "fully defined".

im working with a large design tree and dont want to open each sketch in order to determine if it was constrained properly.

Is a Macro a possibilty?
 
Replies continue below

Recommended for you

Look for the minus sign to the left of the sketch in the feature manager tree.

Bradley
SolidWorks Premim 2007 x64 SP3.1
PDM Works, Intel(R) Pentium(R) D CPU
3.00 GHz, 4 GB RAM, Virtual memory 12577 MB, nVidia 3400
 
I believe malis is looking for a means of differentiating between dimension-(or feature)-constrained and just fixed-in-place (using the "anchor" constraint option) sketch entities in a fully defined sketch. Not whether a sketch is defined or under-defined.

I do not know of a way and I'm not sure that even API can do that ... but then I'm API illiterate.

[cheers]
 
Now I'll sit back and wait for handleman or fcsuper or ??? to say, "Sure you can, it's easy". [lol]

[cheers]
 
Sure you can, it's easy! ;-)

Code:
Dim swApp As SldWorks.SldWorks
Dim AllFeatures As Variant
Dim allRelations As Variant
Dim allChild As Variant
Dim i As Long
Dim j As Long
Dim mySketch As Sketch
Dim RelMgr As SketchRelationManager
Dim ResultString As String
Dim ChildNames As String
Dim FixedCount As Long

Sub main()

Set swApp = Application.SldWorks
ResultString = ""
AllFeatures = Empty
AllFeatures = swApp.ActiveDoc.FeatureManager.GetFeatures(False)

For i = 0 To UBound(AllFeatures)
    If AllFeatures(i).GetTypeName = "ProfileFeature" Then
        Set mySketch = AllFeatures(i).GetSpecificFeature
        If Not (mySketch Is Nothing) Then
            Set RelMgr = mySketch.RelationManager
            allRelations = Empty
            allChild = Empty
            allRelations = RelMgr.GetRelations(swAll)
            allChild = mySketch.GetChildren
            FixedCount = 0
            For j = 0 To UBound(allRelations)
                If allRelations(j).GetRelationType = swConstraintType_FIXED Then
                    FixedCount = FixedCount + 1
                End If
            Next j
            ChildNames = " ("
            For j = 0 To UBound(allChild)
                ChildNames = ChildNames & allChild(j).Name & ", "
            Next j
            ChildNames = Left(ChildNames, Len(ChildNames) - 2) & ")"
            If FixedCount > 0 Then
                ResultString = ResultString & vbCrLf & FixedCount & " -" & mySketch.Name & ChildNames
            End If
        End If
    End If
Next i

MsgBox "Quantity of ""Fixed"" relations" & vbCrLf & "per sketch in this model:" & vbCrLf & ResultString
End Sub
 
Some additional explanation is probably in order. This macro will find all the sketches in the currently active document and check each relation to see if it is of the "Fixed" type. It will report in a message box the quantity of fixed relations, the name of the sketch, and the feature in which it's located for each sketch containing fixed relations. I haven't done a whole lot of testing on this, but it appears that hole wizard holes all have one fixed relation in their profile sketch.
 
CBL,

Thanks for the vote of confidence, but I'm just a hack with an ever-growing library. handleman is the pro coder here that comes up with this stuff from scratch all the time. [smiley]

mails,

I'm curious as to why you are wanting to check sketches with fixed vs. dim'd constraints?



Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group
 
Im teaching a SW class and have caught several individuals not correctly constraining there model. They are fudging there sketches.
 
They arent dimensioning the sketch period. Just making it look like the example and then fixing everything. Therefore the model isnt dimensionaly correct.
 
So, it's pretty much just a lesson requirement. I agree with Tick's appearant criticism otherwise, because there's really nothing wrong with using Fixed, since technically, every point on a sketch refers back to something that is fixed, whether it be the origin, self-fixed or another fixed entity...just as long as the behavior of that entity produces expected (intuitive) results when the sketch is later edited, IMO.

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group
 
I see. I suppose for training you don't want that. Fix does have its place, though.

A macro is definitely possible. An addin could be more useful for constant monitoring.

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
TheTick said:
Fix does have its place, though.
[yoda]<--"Listen to ID-Vador you should not... to the dark side he will lead you...
[lightsaber]

Windows XP / Microsoft Wireless Optical Mouse 5000 / SolidWorks 2007 SP2.2 / SpaceBall 5000
"Right-click. It's friggin' magic!"... Jack L. Tate
FAQ376 I'm famous.
 
handleman, I'm getting run-time errors on ubound on some models (either For j = 0 lines). I can't seem to track down why the code is being picky. It doesn't seem to like some models without a reason I can figure out.

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group
 
Does the error always occur with certain files? If so, upload one to Mooload if you can. I seem to currently have access to that at work. I guess Mooload made some changes and Websense hasn't caught up.
 
Use fully define sketch in a 2d sketch -- (to quote TateJ) Its friggin magic.

RFUS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor