#1
|
||||
|
||||
remove workplanes from drawlist
I am trying to write a lisp program that will go through the existing drawlist and remove workplanes from that drawlist. This is what I currently have. I know it is not right, but it is an attempt. If anybody can provide pointers as to the correct commands, I would appreciate it.
Thanks Tom Code:
(in-package :custom) (use-package :OLI) ;;--------------------------------------------------------------------------* (sd-defdialog 'remove_workplanes :dialog-title "Remove Workplanes" :toolbox-button T ;;:dialog-control :sequential :variables '( ) :local-functions '( (wpremove-action () (let (viewportlist worklist) (setf viewportlist (sd-inq-vp-drawlist-objects (oli::sd-inq-current-vp))) (dolist (worklist viewportlist) (if (sd-inq-workplane-p worklist)(remove_from_vp_drawlist worklist)) );;dolist );;let ) ) :ok-action '(sd-call-cmds (wpremove-action)) :help-action '() )
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com |
#2
|
|||
|
|||
Re: remove workplanes from drawlist
Hi Tom,
You're on the right track -- you were only missing one parameter (the viewport) on the function to remove the object from the drawlist. You can do it with an even simpler method, though. There's no need to include empty sections, and you can also avoid some of the intermediate variables and function definitions. In this case, I just decided to use a variable with an :initial-value statement to run the code -- no separate function calls or function definition required! As soon as you press the toolbox button, the workplanes will be removed (no dialog on screen). If you prefer the dialog to be displayed and then press a button to remove the workplanes, just change :initial-value to :push-action. Here's what I came up with: Code:
(in-package :custom) (use-package :oli) (sd-defdialog 'remove_workplanes :dialog-title "Remove Workplanes" :toolbox-button t :variables '((remove-wps :initial-value ;; this will be executed when the dialog starts (let ((vp (sd-inq-current-vp))) (dolist (obj (sd-inq-vp-drawlist-objects vp)) (when (sd-inq-workplane-p obj) (remove_from_vp_drawlist vp obj))) ;; after processing all items, cancel this dialog (sd-put-buffer "cancel")))) ) 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! |
#3
|
||||
|
||||
Re: remove workplanes from drawlist
Andy
Thank you. This definitley simplifies what I was trying to do. Tom
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com |
#4
|
||||
|
||||
Re: remove workplanes from drawlist
Andy
This works well unless the workplane is buried deep in sub assemblies. I added the line (display obj) just to see what is being processed. It seems only look into objects in the root or top level assembly. Any ideas? The assembly I have has 112,414 parts, in 10135 assemblies. Tom
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com |
#5
|
|||
|
|||
Re: remove workplanes from drawlist
Quote:
Yeah, that actually makes sense -- querying the drawlist only gives you the highest-level object that can completely identify what's displayed. If you have a single assembly loaded with 100,000 objects in it, and that entire assembly is turned on, querying the drawlist will only show a single object (the top-level assembly). So, rather than trying to figure out which workplanes are shown, we can just query all objects in the system, and turn off only the workplanes. There are inefficiencies both ways, but this may be the quickest and cleanest. Here's the next pass: Code:
(in-package :custom) (use-package :oli) ;; Define a function to return a list of all child objects of a given object ;; Then call it recursively to get a list of all objects under the initial ;; top-level object. (defun inq-obj-tree-list (obj) (cons obj (apply #'nconc (mapcar #'inq-obj-tree-list (sd-inq-obj-children obj))))) (sd-defdialog 'remove_workplanes :dialog-title "Remove Workplanes" :toolbox-button t :variables '((remove-em :initial-value (let ((vp (sd-inq-current-vp))) (dolist (obj (inq-obj-tree-list (sd-pathname-to-obj "/"))) (when (sd-inq-workplane-p obj) (remove_from_vp_drawlist vp obj))) (sd-put-buffer "cancel")))) ) Does that do the trick for you? How long does it take to process all objects? I think it should be fairly quick, but I don't have any assemblies that size...
__________________
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! |
#6
|
||||
|
||||
Re: remove workplanes from drawlist
Code:
(defun inq-obj-tree-list (obj) (cons obj (apply #'nconc (mapcar #'inq-obj-tree-list (sd-inq-obj-children obj))))) This code worked, it took 7 seconds from start to finish. This is a big improvement over the hunt method used before. Thanks for your help with this Tom
__________________
Tom Kirkman Creo Elements/Direct 20.1 Dell Precision 3581 https://www.o-i.com |
#7
|
|||
|
|||
Re: remove workplanes from drawlist
Quote:
Quote:
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! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | Rate This Thread |
|
|