#1
|
|||
|
|||
Creating my own "Text References"
I have created a "group" in the am_customize file and can chose it in Annotation as a Text Reference group... and I could probably figure out how to add "objects"?? to that group, but haven't yet.
What I want to know is how do I link one of those "objects"?? to a 3D part and have that "word" appear automatically in Annotation as a Text Reference?? What I'm trying to do...: I want to add material types to my 3D parts and have it show up automatically on my drawings and in BOMs. I'm sure the help files can show me how to do this but I can't decipher them and test it all out during work time as I've already been cursed by the bosses for "wasting" time on this... They can't see that this will save time in the future! I don't have a Model Manager license so I can't assign materials that way. Thanks!! Wolfgang, John Scheffel, anyone... Please help!! |
#2
|
|||
|
|||
Re: Creating my own "Text References"
Oppss... Sorry for submitting this twice...
|
#3
|
|||
|
|||
Re: Creating my own "Text References"
I think you require lisp to do this. You can create your own text references which have a lisp function behind it. Whenever the text reference is updated the function is called and the return value is put in the text field. You could make a function which returns a value stored in the model.
Here is an example of how the lisp code could look like. This code isn't tested, so it probably contains some errors. It's just for giving you a start: Code:
(in-package :YOURPACKAGE) (use-package :docu) (use-package :oli) ;//// Define text-reference fields (DOCU-REGISTER-TR-TYPE "GROUPNAME" "FIELDNAME" "" 'functionname) (defun functionname () (let (sheet owner text) (setf sheet (sd-am-inq-curr-sheet)) (when sheet (setf owner (vb-get-sheet-owner sheet)) (when owner (setf text (your_function_to_get_the_material_from_model owner)) );end when );end when ;//// Return the text (if text text ;return the text ;else "" ;return an empty string );end if );end let );end defun (defun vb-get-sheet-owner (sheet) (let (view owner) (when sheet (setf view (first (sd-am-sheet-struct-views (sd-am-inq-sheet sheet)))) (if view (progn (when (sd-am-view-struct-view-set (sd-am-inq-view view)) (setf owner (sd-am-view-set-struct-owner (sd-am-inq-view-set (sd-am-view-struct-view-set (sd-am-inq-view view))))) );end when );end progn ;else (progn (setf view (first (sd-am-sheet-struct-flats (sd-am-inq-sheet sheet)))) (when view (setf owner (sd-am-view-struct-parts-3d (sd-am-inq-view view))) );end when );end progn );end if );end when owner );end let );end defun With kind regards, Marten |
#4
|
|||
|
|||
Re: Creating my own "Text References"
Marten,
Thanks HEAPS!! Haven't tried your code yet but I will as soon as I get to work tomorrow! There's a LOT in there that I'm gonna have to find out what it all means but I've done heaps of C & bash programming so it can't be that hard (hopefully!!)... But I'm a serious NEWBIE to LISP... But ya gotta start somewhere right!!? Could you be so kind as to point me at any good sites that focus on the Lisp functions used in CoCreate? The help that comes with CC ain't all that good! Another question... Am I going about this all wrong?? Is there a better way of assigning materials to my parts that can appear in my BOMs without a Model Manager license?? Thanks again Marten! BIG HELP!! |
#5
|
|||
|
|||
Re: Creating my own "Text References"
Hi,
Claus Brod has got the most information online I guess http://www.clausbrod.de/cgi-bin/view.pl/CoCreateModeling/WebHome. I mainly used the Lisp Training from CoCreate to get a start. From that point on it was just trying and searching the documentation for the right functions. It's not ideal, but it is doable. In the beginning lisp can be a bit frustrating. Many things work slightly different than other languages and you have to get used to the bracket notation. But after a while I really started to see the power of lisp and now I like the language a lot. In my opinion it is the best language CoCreate could have picked to build powerfull extensions to the software. You are constantly working with lists and lisp is really good at that (and it's fast as well). I only hope they add some more advanced lisp functionallity, as the lisp core is a little bit outdated (it doesn't support object orientation). Good luck with learning lisp and make sure you pass the first hurdle. The method I described doesn't need ModelManager. If you use ModelManager you can pass ModelManager data over to annotation to get it into text references. As far as I know this is only drawing data and not model data (as a drawing can contain multiple models). The function which gets called to return the models material defines which data is returned. If you use the ModelManager data this function should return that data. You could also add a material attribute to the model and return that data with the function. In that case you don't need ModelManager at all. Hope this helps. Regards, Marten |
#6
|
|||
|
|||
Re: Creating my own "Text References"
I’ve had a chance to play around with your code but I have a couple of questions about how things work in CoCreate programming…
From what I’m gathering in your code, the line : Code:
(DOCU-REGISTER-TR-TYPE "GROUPNAME" "FIELDNAME" "" 'functionname) THEN it’s calling the function “functionname” to get the value that the text reference should be displayed as….. RIGHT?? The function asks the current sheet “what part do you have on you?” (storing it in the variable “owner”) then the line : Code:
(setf text (your_function_to_get_the_material_from_model owner)) Am I right so far?? I have some other code that I “borrowed” that attaches attributes to parts in 3D. I’m loading this code in a completely different file… I have replaced “your_function_to_get_the_material_from_model” with the function name from this other file… Will the code in one file, your code, recognise the function loaded from another file?? As long as the other file is loaded first? Or does it all have to be in the same file?? Also… Typing : Code:
(display "Hello world!") I know I’m being “needy” but, particularly my last question, will put me on the right path! Thanks again Marten |
#7
|
||||
|
||||
Re: Creating my own "Text References"
Hi,
Sorry the reply took so long, but I wasn't at the office for two weeks... Quote:
Quote:
Quote:
Quote:
Code:
(display (packagename::functionname)) If you want to pass a model as parameter: Code:
(display (packagename::functionname (oli::sd-pathname-to-obj "/partname"))) Good luck! With kind regards, Marten |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|