f



API:Get custom prop from referenced model

I have a macro that I use to generate a pdf of an open drawing.  My drawing 
filename is simply the part number.  I want to Macro to append a revision 
to the end of the filename before saving as a pdf.  I carry the current rev 
in a custom propety in the model.  I have a note on my sheet format that 
references this to diplay the rev in the title block.

I can't seem to use part.getcustominfo2 because it looks in the custom 
property area of the drawing (which is empty)

I do not know how to access the properties of the referenced model like my 
notes do ($PRPSHEET:REV).

Any ideas how to do this.  I know only enough VB to find my way around the 
help file.  I have not gotten anywhere with this.  I think I could use 
Note.GetPropertyLinkedText if I knew how to point to the note.  

Any tips would be appreciated.

MHill
0
4/21/2004 6:55:34 PM
comp.cad.solidworks 14446 articles. 2 followers. Post Follow

3 Replies
5221 Views

Similar Articles

[PageSpeed] 25

You are in luck I just wrote this a month or 2 ago. It figures out which
view is the one used for custom properties on the current sheet then
connects to the referenced part (which I believe Deb posted an easier way of
getting the referenced part recently, I had used the long way) and gets the
Description field (I handled it so that this is not case sensitive) and adds
the same field to the drawing. You can easily modify it to get any field you
want, I hadn't handled config specific properties, because I almost never
use them.


Option Compare Text 'this line needs to be at the top of the module
'so that it compares non-case sensitive

Private Function swDrw_FileSaveNotify(ByVal fileName As String) As Long

    Dim ThisSheet       As SldWorks.Sheet
    Dim ThisView        As SldWorks.view
    Dim ThisViewName    As String
    Dim ModelName       As String
    Dim ThisModel       As SldWorks.ModelDoc2
    Dim Description     As String
    Dim CustomInfoNms() As String
    Dim Count           As Long

    Set ThisSheet = swDrw.GetCurrentSheet
    ThisViewName = ThisSheet.CustomPropertyView
    Set ThisView = swDrw.GetFirstView

    Do While Not ThisView Is Nothing
        If ThisViewName = ThisView.Name Then
            Exit Do
        End If
        Set ThisView = ThisView.GetNextView
    Loop

    If ThisView Is Nothing Then
        Set ThisView = swDrw.GetFirstView
        ModelName = ThisView.GetReferencedModelName
        While ModelName = "" And Not ThisView Is Nothing
            Set ThisView = ThisView.GetNextView
            If ThisView Is Nothing Then Exit Function
            ModelName = ThisView.GetReferencedModelName
        Wend
        If ThisView Is Nothing Then Exit Function
    End If
    Set ThisModel = swApp.GetOpenDocumentByName(ModelName)

    CustomInfoNms = ThisModel.GetCustomInfoNames2("")
    Count = 0
    Description = ""
    'Find  the Field labled Description and set that value
    For Count = 0 To UBound(CustomInfoNms)
        If CustomInfoNms(Count) = "description" Then
            Description = ThisModel.GetCustomInfoValue("",
CustomInfoNms(Count))
            Exit For
        End If
    Next

    If Description = "" Then Exit Function
    If Not ActvDoc.GetPathName = fileName Then MsgBox "Caution Active doc
is: " & ActvDoc.GetTitle & vbcrlf & "This was not the document you started
with!!!!

'the Rest of the lines set the Description field of the drawing to be the
same as the
'referenced model

    CustomInfoNms = ActvDoc.GetCustomInfoNames2("")
    Count = 0

    For Count = 0 To UBound(CustomInfoNms)
        If CustomInfoNms(Count) = "description" Then
            retval = ActvDoc.DeleteCustomInfo2("", CustomInfoNms(Count))
        End If
    Next
    retval = ActvDoc.AddCustomInfo3("", "Description", 30, Description)
End Function

Regards,

Corey Scheich

"MHill" <mhillDELETE@banksREMOVEpower.com_> wrote in message
news:108dgt6h3nee795@news.supernews.com...
> I have a macro that I use to generate a pdf of an open drawing.  My
drawing
> filename is simply the part number.  I want to Macro to append a revision
> to the end of the filename before saving as a pdf.  I carry the current
rev
> in a custom propety in the model.  I have a note on my sheet format that
> references this to diplay the rev in the title block.
>
> I can't seem to use part.getcustominfo2 because it looks in the custom
> property area of the drawing (which is empty)
>
> I do not know how to access the properties of the referenced model like my
> notes do ($PRPSHEET:REV).
>
> Any ideas how to do this.  I know only enough VB to find my way around the
> help file.  I have not gotten anywhere with this.  I think I could use
> Note.GetPropertyLinkedText if I knew how to point to the note.
>
> Any tips would be appreciated.
>
> MHill


1
Corey
4/21/2004 8:39:50 PM
"Corey Scheich" <cscheich@garlockequip.com> wrote in
news:c66lr0$8o5qh$1@ID-200385.news.uni-berlin.de: 

> You are in luck I just wrote this a month or 2 ago. It figures out
> which view is the one used for custom properties on the current sheet
> then connects to the referenced part (which I believe Deb posted an
> easier way of getting the referenced part recently, I had used the
> long way) and gets the Description field (I handled it so that this is
> not case sensitive) and adds the same field to the drawing. You can
> easily modify it to get any field you want, I hadn't handled config
> specific properties, because I almost never use them.
> 
> 
> Option Compare Text 'this line needs to be at the top of the module
> 'so that it compares non-case sensitive
> 
<snip macro code>


Thanks Corey, I'll give it a try.  I kind of thought I might have to 
interrogate the drawing like that but had no idea how to actually 
accomplish it.

MHill
0
MHill
4/21/2004 8:40:35 PM
I noticed that Corey gave you some code to get the properties of the
referenced model, which is great, but if the data you want is already
in a note, you can also access that note.  You can use the SelectByID
function to select a note with its name.  The only problem is that I
have found no way to see a note's name in SolidWorks other than
through the API.  So, I wrote an addin that just allows you to view
and change the names of notes.  Once you know the name (usually you
want to save it in a sheet format or some such so it is the same name
on all your drawings), it's easy to read and change the note text. 
Basically you do something like this (forgive me if it's not quite
correct - I mostly use C++):

Part.Extension.SelectByID "NoteName@SheetFormatName", "NOTE", 0, 0, 0,
False, 0, null
Note = Part.SelectionManager.GetSelectedObject5(1)
text = Note.GetText

So that's pretty easy, except you may want to add some error checking.
 I use the SetText method to fill in a lot of notes.  We have a
spreadsheet set up for our different sheet formats that has the note
names in one column and the note text in another.  That way it's
really easy for the guys to enter all the info quickly.  Then they
just click a button, and a VB macro fills in all the notes for them. 
I know you can do some of the same stuff with custom properties, but
that's how we do it.  If you want a copy of the addin for setting
notes, send me an email.  Be sure to use my name in the email or it'll
get deleted.  Zipped, the file is only 25 KB, so it's no problem with
email.  It does require MFC 7.1 and the visual C++ runtime 7.1 though,
which you should be able to get from Microsoft or just search for
them.  The specific ones are mfc71u.dll and msvcr71.dll.

Jonathan Anderson
janderson@jwoperating.com
Include my first name in the body or subject of an email to get past
my filters.

MHill <mhillDELETE@banksREMOVEpower.com_> wrote in message news:<108dgt6h3nee795@news.supernews.com>...
> I have a macro that I use to generate a pdf of an open drawing.  My drawing 
> filename is simply the part number.  I want to Macro to append a revision 
> to the end of the filename before saving as a pdf.  I carry the current rev 
> in a custom propety in the model.  I have a note on my sheet format that 
> references this to diplay the rev in the title block.
> 
> I can't seem to use part.getcustominfo2 because it looks in the custom 
> property area of the drawing (which is empty)
> 
> I do not know how to access the properties of the referenced model like my 
> notes do ($PRPSHEET:REV).
> 
> Any ideas how to do this.  I know only enough VB to find my way around the 
> help file.  I have not gotten anywhere with this.  I think I could use 
> Note.GetPropertyLinkedText if I knew how to point to the note.  
> 
> Any tips would be appreciated.
> 
> MHill
0
janderson
4/22/2004 6:08:45 PM
Reply:

Web resources about - API:Get custom prop from referenced model - comp.cad.solidworks

Criterion-Referenced Competency Tests - Wikipedia, the free encyclopedia
The Criterion-Referenced Competency Tests (CRCT) are a set of tests administered at public schools in the state of Georgia that are designed ...

SmartPlates & Charts - Geo-referenced VFR & IFR Maps and Procedures on the App Store on iTunes
Get SmartPlates & Charts - Geo-referenced VFR & IFR Maps and Procedures on the App Store. See screenshots and ratings, and read customer reviews. ...

Gay rights referenced in new citizenship guide
A revised citizenship study guide for new Canadians released Monday contains a single sentence on gay and lesbian rights, which is a sentence ...

Google Glass bone conduction technology referenced in FCC filing
As if Google Glass wasn't already cool enough, today we're finding out that it feature bone conduction technology. The glasses recently made ...

Retina-Equipped iMac Referenced In OS X 10.10 Yosemite
... to receive an ultra-high resolution display. According to MacBidouille ( via MacRumors ), a Retina display-equipped iMac is indeed referenced ...

Facebook profiles: now cross-referenced with retail purchases!
CVS is one of the companies that manages its loyalty program data with Facebook's new partner, Datalogix. Elvert Barnes Facebook is now using ...

CBS News releases video referenced in O'Reilly dispute
NEW YORK (AP) — CBS News on Monday released video from four stories it aired about the Falklands War in 1982, all part of a dispute involving ...


"I don't think anything can prepare you to hear your own name referenced by a Supreme Court justice as ...
"If I remember correctly, 'Gratz' was referenced in the very first question asked that day. Each time they mentioned my name, I wanted to jump ...

Can You Name All 85 Best Picture Winners Referenced In This Wonderful Oscars Ad?
Designer Olly Moss said this poster for the Oscars was the hardest he's ever had to create. The brief: reference every single Best Picture winner ...

Resources last updated: 1/24/2016 1:15:16 PM