CoCreate User Forum  

Go Back   CoCreate User Forum > Applications > Annotation
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 08-10-2010, 03:10 AM
ash_ai ash_ai is offline
Registered User
 
Join Date: Aug 2010
Posts: 6
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!!
Reply With Quote
  #2  
Old 08-10-2010, 03:22 AM
ash_ai ash_ai is offline
Registered User
 
Join Date: Aug 2010
Posts: 6
Re: Creating my own "Text References"

Oppss... Sorry for submitting this twice...
Reply With Quote
  #3  
Old 08-10-2010, 11:33 PM
Marten Marten is offline
Registered User
 
Join Date: Feb 2006
Location: Tilburg, The Netherlands
Posts: 139
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
Hope this helps.

With kind regards,

Marten
Reply With Quote
  #4  
Old 08-12-2010, 03:46 AM
ash_ai ash_ai is offline
Registered User
 
Join Date: Aug 2010
Posts: 6
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!!
Reply With Quote
  #5  
Old 08-12-2010, 05:04 AM
Marten Marten is offline
Registered User
 
Join Date: Feb 2006
Location: Tilburg, The Netherlands
Posts: 139
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
Reply With Quote
  #6  
Old 08-13-2010, 02:21 AM
ash_ai ash_ai is offline
Registered User
 
Join Date: Aug 2010
Posts: 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)
will create a text reference called “FIELDNAME” (which I’m calling “Material”) in the text reference group “GROUPNAME” (which I’m giving as “BFG” so it can be in my BOM)
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))
calls another function, with “owner” as the argument, for the value of that attached attribute.

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!")
in the user input bar in CoCreate will, obviously, display "Hello world!" in the output window… Do you know how to display the value of variables in the same output window? Just for testing purposes… And not just variables but can I type functions and see their return value somehow??

I know I’m being “needy” but, particularly my last question, will put me on the right path!

Thanks again Marten
Reply With Quote
  #7  
Old 09-01-2010, 06:02 AM
Marten Marten is offline
Registered User
 
Join Date: Feb 2006
Location: Tilburg, The Netherlands
Posts: 139
Re: Creating my own "Text References"

Hi,

Sorry the reply took so long, but I wasn't at the office for two weeks...

Quote:
From what I’m gathering in your code, the line :
Code:
(DOCU-REGISTER-TR-TYPE "GROUPNAME" "FIELDNAME" "" 'functionname)
will create a text reference called “FIELDNAME” (which I’m calling “Material”) in the text reference group “GROUPNAME” (which I’m giving as “BFG” so it can be in my BOM)
THEN it’s calling the function “functionname” to get the value that the text reference should be displayed as….. RIGHT??
Yes, you are right. However, I believe BFG is a default group. I'm not sure if you can use the default groups. I just added my own name.


Quote:
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))
calls another function, with “owner” as the argument, for the value of that attached attribute.

Am I right so far??
Yes, you are right.

Quote:
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??
If they are in the same package everything is ok (see the first line of my code: you can replace YOURPACKAGE). If the package name is different you have to prefix (i.e. (packagename::functionname) or use in-package. In this case the function you call should be loaded first (more specifically: the package should already exist before you load the text reference file, otherwise loading the function will fail).

Quote:
in the user input bar in CoCreate will, obviously, display "Hello world!" in the output window… Do you know how to display the value of variables in the same output window? Just for testing purposes… And not just variables but can I type functions and see their return value somehow??
Yes you can:

Code:
(display (packagename::functionname))
will display the result of the function.

If you want to pass a model as parameter:

Code:
(display (packagename::functionname (oli::sd-pathname-to-obj "/partname")))
This way you can check if your function returns the right information.

Good luck!

With kind regards,

Marten
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 06:37 AM.



Hosted by SureServer    Forums   Modeling FAQ   Macro Site   Vendor/Contractors   Software Resellers   CoCreate   Gallery   Home   Board Members   Regional User Groups  By-Laws  

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.