CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 10 votes, 5.00 average. Display Modes
  #1  
Old 05-24-2010, 02:06 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Macro Annotation

Hi!

I do this macro in LISP:
(in-package :trive)
(use-package :oli)



(sd-defdialog 'GEOM_PART
:dialog-title "From Geometry To Part"
:dialog-control :parallel
:variables '(

(geometry :selection *sd-anno-geo-seltype*
:multiple-item nil
:title "Geometry"
:prompt-text "Sel. geometry"
:after-input (progn
(display (format nil "Geometry seltype ~A" geometry))
(display (format nil "Geometry seltype ~A" (sd-am-inq-name geometry)))
(display (format nil "Geometry ID ~A" (sd-get-annotator-reference :object geometry)))
(display (format nil "Parameter 301 ~A" (sd-execute-annotator-function :fnc (format nil "From_geometry_to_part '~A' 301" (sd-am-inq-name geometry)))))
)
)

)

:ok-action
()
)


(sd-execute-annotator-command :cmd (format nil
"~a ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a"
"DEFINE From_geometry_to_part"
"PARAMETER target_pid"
"PARAMETER number_code"
"LOCAL output"
"INQ_ELEM target_pid"
"LET output (INQ number_code)"
"LET output (DOCU_CSTRING_TO_LSTRING output)"
"(DOCU_OPEN_CONNECTION_TO_SD)"
"(DOCU_ADD_LINE_TO_SD output)"
"(DOCU_CLOSE_CONNECTION_TO_SD)"
"END_DEFINE"
)
)

This function works in Annotation.

I select a geometry, line, circle... ecc. and the macro return the name of part.

But I want also to return the complete path of the part...

Now I have this,
part

But I want this
/group/part...

Thank you in advance
Michele
Reply With Quote
  #2  
Old 06-04-2010, 08:58 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Lightbulb Re: Macro Annotation

Drafting (and so the Annotator.exe) does not offer a INQ for the complete PATH as you would like to see.

You have to do a loop
- change_part parent
- inq_part .
- inq part name
- add part name to path
......
until you hit the root (part name = "/")

I assume you should skip the last part added, since this will be the sheet number.

Be aware that strings in Drafting are limited to 1023 chars. So concatenating all the part levels to one long string will break it sooner or later. TIP: Add all the levels to a LISP list returned to your dialog and create the long string over there with a simple
PHP Code:
(setq path (format nil "~{/~A~}" path-list)) 
or use:
Code:
IKIT  ---  sd-pathlist-to-pathname
---------------
oh.. and Michele, please use the [ code ] tag when writing code in this forum. Have a look to the 'BB code' link a the end of the page when writing a post.

Last edited by Wolfgang; 06-04-2010 at 09:00 AM. Reason: added hint to BB code
Reply With Quote
  #3  
Old 06-15-2010, 02:25 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Thank you for the replay...

But I don't understand very well...

I look for the macro change_part... but I don't find it!

If you do a little example...

Thank you in advance
Ciao
Michele
Reply With Quote
  #4  
Old 06-15-2010, 07:39 AM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Macro Annotation

Hi Michele,

I believe the macro command Wolfgang meant is

edit_part (rather than change_part)

Does that help!

andy
__________________
Andy Poulsen
AI MAXTools: Dream. Design. Done. It's that easy!
Add-ins bringing new functionality and speed to Creo Elements/Direct and CoCreate products. Now available for v17-v20+!
See them in action at www.ai-maxtools.com and then try them for yourself -- FREE!
Reply With Quote
  #5  
Old 06-16-2010, 04:37 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Hi..
Thank you for the response...

I try with this macro
Code:
(sd-execute-annotator-command :cmd (format nil
        "~a ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a ~a"
        "DEFINE From_geometry_to_part_parent"
        "PARAMETER target_pid"
        "PARAMETER number_code"
        "LOCAL output"
        "INQ_PART target_pid"
        "EDIT_PART PARENT"
        "LET output (INQ number_code)"
        "LET output (DOCU_CSTRING_TO_LSTRING output)"
        "(DOCU_OPEN_CONNECTION_TO_SD)"
        "(DOCU_ADD_LINE_TO_SD output)"
        "(DOCU_CLOSE_CONNECTION_TO_SD)"
        "END_DEFINE"
        )
)
And this macro return me only the name of view and not the parent of the part...

Thank you in advance
Ciao
Michele
Reply With Quote
  #6  
Old 06-18-2010, 11:37 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Re: Macro Annotation

@Andy .. there is a change_part available.. in newer versions.. and it's not documented AFAIK

@Michele
Attached is a macro file. I recommend to use Notepad++ with the CoCreate syntax highlighting activated. This makes editing easier, because is also help checking the syntax.

Another reason is that sd-execute-annotator-command is limited to send a maximum of ~1000 chars as a single string. Once you exceed that value you will get strange and funny results with your macro, because it's not complete. (if you get a result at all, because chances are high to get a hang-up in this case)



You have to adjust the LISP call of the macro since I removed the 2nd parameter with the INQ number. The macro is now too special to pass through that number, I think.

On the LISP side you will get back a list of string as I mentioned in my first post. Make a single string out of it as I showed earlier.

remark: the macro is only written. I did not test it. I think you will get it to work. Let us know.
Attached Thumbnails
Click image for larger version

Name:	inq_part_path_m.png
Views:	1836
Size:	15.8 KB
ID:	1689  
Attached Files
File Type: m inq_part_path.m (1.5 KB, 442 views)

Last edited by Wolfgang; 06-18-2010 at 11:44 AM. Reason: include image in text
Reply With Quote
  #7  
Old 06-21-2010, 01:29 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Hi!
Thank you for your help.

But the macro doesn'nt work....

I changhe the macro in the while like this
Code:
WHILE (INDICE < 3)

    (DOCU_ADD_LINE_TO_SD CSTRING_TO_LSTRING work_pname))
    EDIT_PART PARENT
    INQ_PART .
    LET work_pname (INQ 301)
    LET INDICE (INDICE + 1)
  END_WHILE
to see what happen.

And the macro return the list of name of the same part...
For example:
(part part)
and not
(group part)...

Thanks in advance

Ciao
Michele
Reply With Quote
  #8  
Old 06-21-2010, 09:41 AM
Wolfgang's Avatar
Wolfgang Wolfgang is offline
Registered User
 
Join Date: Nov 2002
Location: ... near Sindelfingen near Stuttgart, Germany
Posts: 754
Re: Macro Annotation

sh.. happens

remove
Code:
INQ_PART .
add
Code:
INQ_PART '.'
or more clear:
Code:
INQ_PART CURRENT
for debugging purpose you can also wrap around logging to file:
Code:
...
trace del_old 'c:/temp/my_macro.log'
while....
end_while
trace off
...
Please try first logging to see the output in the trace file. I assume somethink like '. is not a valid part name' or so.

On the LISP side you need a (reverse ..) in addition
PHP Code:
(setq path (format nil "~{/~A~}" (nreverse raw-path-list))) 
Attached Thumbnails
Click image for larger version

Name:	inq_part_path_m.png
Views:	447
Size:	19.6 KB
ID:	1691  
Attached Files
File Type: m inq_part_path.m (1.5 KB, 445 views)
Reply With Quote
  #9  
Old 06-22-2010, 08:04 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Hi, Wolfang....

Unfortanely the macro doens't work!!!

I try and the macro return:

(name_of_part 1 name_of_drawing)

I attach the logfile and you can see the "parte1" is the correct name of part, "1" I don't know and "gruppo15" is the name of Annotation's drawing...

To stop the loop i use an index.... to do only 4 loop.

Another question, but I see one ) more in your code:
Code:
(DOCU_ADD_LINE_TO_SD CSTRING_TO_LSTRING work_pname))
It's ok?


Thanks in advance
Ciao
Michele
Reply With Quote
  #10  
Old 06-22-2010, 08:07 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Sorry the log file!!!!

Michele
Attached Files
File Type: txt my_macro.txt (1.1 KB, 566 views)
Reply With Quote
  #11  
Old 06-22-2010, 11:17 PM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Hi,
I understand what it is
Quote:
I attach the logfile and you can see the "parte1" is the correct name of part, "1" I don't know and "gruppo15" is the name of Annotation's drawing...
1 is a name of sheet....

But the three in Me10 of sheet is in attached photo.

Ciao
Michele
Attached Thumbnails
Click image for larger version

Name:	example.jpg
Views:	486
Size:	85.2 KB
ID:	1699  
Reply With Quote
  #12  
Old 01-02-2011, 11:30 PM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

I have found the solution...
This macro accept in input the point of geometry and return the list with the name of part group name of view...

Ciao
Michele
Attached Thumbnails
Click image for larger version

Name:	From_point_to_part_parent.jpg
Views:	528
Size:	124.7 KB
ID:	1767  
Reply With Quote
  #13  
Old 07-11-2011, 02:49 AM
micgiul micgiul is offline
Registered User
 
Join Date: Sep 2007
Posts: 34
Re: Macro Annotation

Hy!

Now I have a new problem.

I create the refline with the attached macro.
But when I update the view the refline disappear.

What happen?

Ciao
Michele
Attached Thumbnails
Click image for larger version

Name:	Macro.jpg
Views:	462
Size:	180.8 KB
ID:	1794  
Reply With Quote
Reply


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

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 07:17 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.
You Rated this Thread: