Attaching documents to models
Creo Elements/Direct Model Manager allows you to attach local files, directories, or CAD documents to the models that are available in the Creo Elements/Direct Manager Server database.
By default, a command for such customized attachments is not available in Creo Elements/Direct Model Manager. To add the command to Creo Elements/Direct Model Manager,
1. Create an attachment document class ($DOC). In addition to the standard system attributes, this class must also include attributes for:
a. NAME
b. VERSION
c. VERSION_ID
d. CADDOC_ELID
e. DESCRIPTION
For information on creating a document class, see Create a class in the Creo Elements/Direct Help.
2. Create a business object which extends from the com.osm.datamgmt.biz.CadDependentDoc class. For more information, see Business logic extension lab.
3. Override the getFileSelectionMode() method such that it returns one of the following values depending on the attachment type.
a. JFileChooser.DIRECTORIES_ONLY
b. JFileChooser.FILES_AND_DIRECTORIES
c. JFileChooser.FILES_ONLY
For example,
public class CustomAttachment extends CadDependentDoc {
public CustomAttachment(WMSession theSession, int theHandle)
throws WMException {
super(theSession, theHandle);
}

@Override
public int getFileSelectionMode() {
// Only allow attaching files
//return JFileChooser.FILES_ONLY;

// allow files and directories
//return JFileChooser.FILES_AND_DIRECTORIES;

// directories only
return JFileChooser.DIRECTORIES_ONLY;
}
}
4. Add the following class definition to your custom.xml file which is located in the Creo Elements/Direct Manager Server installation directory. For more information, see XML File Management.
<ClassDefs>
<Class extends="BASE_CREO_ATTACHMENT">
<Name>CUSTOM_ATTACHMENT</Name>
<DisplayName>Custom Attachment</DisplayName>
<ClassDescription>Custom Attachment Class</ClassDescription>
<BusinessObjectClass>com.acme.biz.CustomAttachment</BusinessObjectClass>
<!-- <IconFile>/com/osm/icons/CreoSimulate_16.png</IconFile> -->
<ZipFileFilter>
<Deny>.*\.bak</Deny>
</ZipFileFilter>
</Class>
</ClassDefs>
The custom attachment command is now added to Creo Elements/Direct Model Manager. To see this command, you must select your custom.xml file when you log on. For information on how to use the custom attachment command, see Attach documents to models in the Creo Elements/Direct Model Manager Help.
Was this helpful?