CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
  #1  
Old 06-13-2012, 03:22 AM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
OSD => Save current WP into .mi file

How can i save current WP into a .mi file?

PHP Code:
(mi_out :select (sd-inq-obj-basename (sd-inq-curr-wp)))
(
mi_out :select (sd-inq-curr-wp)) 
I tye this but it doesn't work...
Some help?
TNX
Reply With Quote
  #2  
Old 06-13-2012, 12:21 PM
Mike Swartz's Avatar
Mike Swartz Mike Swartz is offline
Registered User
 
Join Date: Jan 2004
Location: Fort Collins
Posts: 322
Re: OSD => Save current WP into .mi file

Workplanes are stored as 3D data, not 2D (*.mi) so it's not going to happen.

It is also not possible to copy the 2d Data from a workplane and paste it into Annotaton or Drafting
Reply With Quote
  #3  
Old 06-13-2012, 11:50 PM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: OSD => Save current WP into .mi file

The command exist, everyday i use this command

From OSD:
Save => Data 2D (.mi) => I select a workplane => name_file_out.mi => OK

So i need only a macro that select in automatic the current workplane
Reply With Quote
  #4  
Old 06-18-2012, 01:46 AM
Henk Stokkel Henk Stokkel is offline
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 36
Re: OSD => Save current WP into .mi file

To store the geometry from a workplane I use this code in a macro of mine:
Code:
(sd-call-cmds 
          (MI_OUT 
            :filename name_of_file
            :overwrite
            :select name_workplane
          )
Reply With Quote
  #5  
Old 06-18-2012, 05:37 AM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: OSD => Save current WP into .mi file

are you sure it works?
Ti give me error.. :/
Reply With Quote
  #6  
Old 06-21-2012, 11:24 PM
Henk Stokkel Henk Stokkel is offline
Registered User
 
Join Date: Aug 2005
Location: Netherlands
Posts: 36
Re: OSD => Save current WP into .mi file

It works fine by me. i use this in a macro to make slices of a 3D object so I can use these contours on a 2.5D milling machine.
Reply With Quote
  #7  
Old 06-22-2012, 03:02 AM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: OSD => Save current WP into .mi file

Look at this:
I don't understand..
Attached Thumbnails
Click image for larger version

Name:	Image3.png
Views:	325
Size:	12.5 KB
ID:	1848   Click image for larger version

Name:	Image4.png
Views:	334
Size:	4.7 KB
ID:	1849  
Reply With Quote
  #8  
Old 06-23-2012, 01:34 AM
ludw ludw is offline
Registered User
 
Join Date: Dec 2006
Location: France
Posts: 83
Re: OSD => Save current WP into .mi file

You should try the following:
Code:
(sd-call-cmds 
  (MI_OUT 
    :overwrite "c:/Temp/wp.mi"
    :select "/w1"
    )
  )
It works for me (18.1 release)
Reply With Quote
  #9  
Old 06-23-2012, 03:32 AM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: OSD => Save current WP into .mi file

For me works grest this:

PHP Code:
(MI_OUT :overwrite (format nil "~A.mi" (string-upcase (sd-inq-obj-basename (sd-inq-curr-wp)))) :select (sd-inq-curr-wp)) 
THANKS!!!
Reply With Quote
  #10  
Old 07-19-2012, 01:42 PM
Shaba's Avatar
Shaba Shaba is offline
Registered User
 
Join Date: Nov 2006
Location: Italy
Posts: 215
Re: OSD => Save current WP into .mi file

I have upgrade my code
But sometimes (i think the first time) give me error and then works well

Someone can help me?
TNX

PHP Code:
(setq des 96)
(
setf filename_mi_out (format nil "~A.mi" (string-upcase (sd-inq-obj-basename (sd-inq-curr-wp)))))
(
loop while (probe-file filename_mi_out) do
   (
setq des (incf des))
   (
setf filename_mi_out (format nil "~A~A.mi" (string-upcase (sd-inq-obj-basename (sd-inq-curr-wp))) (code-char des)))

);;while
(
MI_OUT
  
:overwrite filename_mi_out
  
:select (sd-inq-curr-wp)

Reply With Quote
  #11  
Old 02-26-2021, 09:21 AM
Fred RINCE Fred RINCE is offline
Registered User
 
Join Date: Mar 2003
Location: Mennecy (France)
Posts: 18
Re: OSD => Save current WP into .mi file

Hi All,

It's a very very old post but i try save WP in MI with right button menu context.

I wrote that for menu:
(sd-browser-add-popup-entry
"parcel-gbrowser"
:entry-type ush
:label (sd-multi-lang-string "Save WP as..." :french "Enregister PdT sous..." )
:is-entry-applicable 'IsWPObj
:menu-action 'saveWP
:new-group t
)

and then, the function:
(defun saveWP (obj name)
(mi_out :filename (format nil "~A.mi" (string-upcase (sd-inq-obj-basename obj))) verwrite :select (BrowserNode-objPath obj))
)

Doesn't works ! And Modeling crash....Any idea ??
Reply With Quote
  #12  
Old 02-26-2021, 11:50 PM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: OSD => Save current WP into .mi file

Hi Fred,

The reason it doesn't work is that calling functions from the structure browser uses different object types (and when the call fails, it can crash Modeling as you noticed).

The problems are in the saveWP function -- you're trying to get the basename of a browser object, which is different from a regular Modeling object.

One thing that can help with functions like this is to break the "decoding" into multiple steps so you can check them along the way. Also, if you use "sd-put-buffer" to make the call, it's less likely to crash Modeling since calls made from the command-line (which is essentially what sd-put-buffer does) have much more robust error handling. You could also have the popup call a dialog, which would also provide more robust error handling.

So, if you make the function have a few more steps, it should work:
Code:
(defun saveWP (obj name)
  ;; create some temporary variables for this function to use
  (let (path fname cmdstr)
    ;; extract the path to the Modeling object
    (setq path (BrowserNode-objPath obj))
    ;; create the filename. Note that we first need to get the object pointed to
    ;;      by the path, and then get that object's basename
    (setq fname (format nil "~A.mi" (string-upcase (sd-inq-obj-basename (sd-pathname-to-obj path)))))
    ;; create the command string that we want to execute, including quotes
    (setq cmdstr (format nil "mi_out :select \"~a\" :filename \"~a\" :overwrite" path fname))
    ;; now execute the command string as though we had typed it into the user input line
    (sd-put-buffer cmdstr)
    )
  )
I hope this helps! If you have any other questions, just ask!

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
  #13  
Old 03-01-2021, 04:20 AM
tom kirkman's Avatar
tom kirkman tom kirkman is offline
Registered User
 
Join Date: Oct 2002
Location: Perrysburg, Ohio
Posts: 393
Re: OSD => Save current WP into .mi file

I have this macro, that takes a workplane, saves it as an MI file and then loads it into annotation.

Code:
(sd-defdialog 'wp2anno
 
 	:dialog-title "WP to Annotation"
  
	:variables
 	'(
		(wptje :initial-value (sd-inq-curr-wp) :value-type :wp :title "Workplane")
	)

 	:local-functions
  	'(
   		(doit ()  
			(mi_out :select :workplane wptje :FILENAME "C:/working/out/plot.mi" :OVERWRITE )
			(AM_LOAD_ANY_MI :FILENAME "C:/working/out/plot.mi")  
		)
	)
	:ok-action 
	'(doit)
)
__________________
Tom Kirkman

Creo Elements/Direct 19.0
DELL Precision 7510
Reply With Quote
  #14  
Old 03-01-2021, 10:13 AM
Fred RINCE Fred RINCE is offline
Registered User
 
Join Date: Mar 2003
Location: Mennecy (France)
Posts: 18
Re: OSD => Save current WP into .mi file

Hi Andy,

I'm very happy somebody answer me :-)....I was very surprise too, to have very quickly answer ! Nice !!
Of course, it works ! I will follow your advices to upgrade this program because, in fact, i want to select more than one WP from Browser and then, store them.
Very happy this forum is still alive !
Thank you for your help
Reply With Quote
  #15  
Old 03-01-2021, 10:17 AM
Fred RINCE Fred RINCE is offline
Registered User
 
Join Date: Mar 2003
Location: Mennecy (France)
Posts: 18
Re: OSD => Save current WP into .mi file

Hi Tom,

Thank you too for your anwser. Like i said, it's very plaisant to see this forum is still alive. Many thanks.
I'm realy new in LISP Modeling code.
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 09: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 - 2021, Jelsoft Enterprises Ltd.
You Rated this Thread: