Operators in Custom properties

Discussion in 'SolidWorks' started by ben, Sep 26, 2007.

  1. ben

    ben Guest

    I want to include some data in my drawing template to show things like
    the area of the part. SW-Surface area doesn't work for me because I
    just need the 2D area contained on say, a 4' x 8' sheet of UHMWPE.
    I've realized I'll probably have to manually enter a value for this
    area, but I then want to take that entered value and multiply it by a
    certain factor like 1.25.

    Ideally, the designer would enter in the area of the part and the
    notes on the drawing would automatically fill themselves in like so...

    Area: 32 square inches
    Material Required: 40 square inches

    Is there a way to multiply values in the value/ text expression box of
    custom properties?

    Ben
     
    ben, Sep 26, 2007
    #1
  2. ben

    That70sTick Guest

    You might be able to do this inside of a design table. DT's are Excel
    sheets, so all of their functions are present.
     
    That70sTick, Sep 26, 2007
    #2
  3. A macro could do this. I wrote a similar macro a while back that takes
    a pre-selected face, finds the area and writes to a custom property
    that is then linked to a note. If the face is changed, the macro must
    be rerun. The macro is handy for extrusion profiles. In your case it
    would need to write two custom properties. Here is a sample:

    Sub main()
    Set swApp = Application.SldWorks
    Set swApp = Application.SldWorks
    Set Model2 = swApp.ActiveDoc
    If (Model2 Is Nothing) Or (Model2.GetType <> swDocDRAWING) Then
    Exit Sub
    End If
    Set DwgDoc = Model2
    Set SelMgr = Model2.SelectionManager
    Count = SelMgr.GetSelectedObjectCount
    If Count <> 2 Then
    swApp.SendMsgToUser "PLEASE SELECT ONE FACE."
    Exit Sub
    End If
    Set selview = SelMgr.GetSelectedObject5(2)

    '***get section properties***
    sectprops = Model2.Extension.GetSectionProperties2(selview)

    '***get area from properties convert to in from m round to 3 decimal
    places***
    area = CStr(Round(sectprops(1) / 0.0254 / 0.0254, 3))

    '***create a custom property in the Drawing***
    retval = Model2.AddCustomInfo3("", "CS AREA", swCustomInfoText, area)

    Model2.EditRebuild3
    End Sub
     
    kevin.p.kenny, Sep 27, 2007
    #3
  4. ben

    j Guest

    One way you can do it is to add a couple of extra sketches/equations to
    the model and then put this into the custom property of the part. This
    will then update should the model update. We do this for stock sizes
     
    j, Sep 27, 2007
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.