×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Identify Fixed Relations
2

Identify Fixed Relations

Identify Fixed Relations

(OP)
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?

RE: Identify Fixed Relations

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

RE: Identify Fixed Relations

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

RE: Identify Fixed Relations

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

cheers

RE: Identify Fixed Relations

2
Sure you can, it's easy!  winky smile

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

RE: Identify Fixed Relations

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.

RE: Identify Fixed Relations

(OP)
Star for Handleman

RE: Identify Fixed Relations

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

RE: Identify Fixed Relations

(OP)
Im teaching a SW class and have caught several individuals not correctly constraining there model. They are fudging there sketches.

RE: Identify Fixed Relations

Why is fix constraint "improper".

batHonesty may be the best policy, but insanity is a better defense.bat
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: Identify Fixed Relations

(OP)
They arent dimensioning the sketch period. Just making it look like the example and then fixing everything. Therefore the model isnt dimensionaly correct.

RE: Identify Fixed Relations

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

RE: Identify Fixed Relations

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.

batHonesty may be the best policy, but insanity is a better defense.bat
http://www.EsoxRepublic.com-SolidWorks API VB programming help

RE: Identify Fixed Relations

Quote (TheTick):

Fix does have its place, though.

pokeTypical "I.D. Speak"...tongue

Windows XP / Microsoft Wireless Optical Mouse 5000 / SolidWorks 2007 SP2.2 / SpaceBall 5000
www.Tate3d.com "Right-click. It's friggin' magic!"... Jack L. Tate
FAQ376 I'm famous.

RE: Identify Fixed Relations

Quote (TheTick):

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
www.Tate3d.com "Right-click. It's friggin' magic!"... Jack L. Tate
FAQ376 I'm famous.

RE: Identify Fixed Relations

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

RE: Identify Fixed Relations

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.

RE: Identify Fixed Relations

Use fully define sketch in a 2d sketch -- (to quote TateJ) Its friggin magic.

RFUS

RE: Identify Fixed Relations

I'll just host them on my FTP later today and post the link here.

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources