cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Auto-fit View on a Selected Part / Assembly

Auto-fit View on a Selected Part / Assembly

A command should be added to the right-click menu in the structure browser to center and auto-fit the viewport on a selected part or assembly.  This will make locating specific items in the viewport much quicker.  Currently I will turn the part on and off by checking and unchecking until I can find it.  A command that does this will be very convenient.

10 Comments
ptc-1796640
1-Newbie

One work-around I often use is to double click on the part in the structure browser so it is highlighted in the viewport. Another related tool might be the draw-only in new viewport. AI MAX ViewHQ, a thrid party tool, is also handy.

FriedhelmK
17-Peridot

As an appendix to the work-around by Greg Matelich.

The disadvantage of "draw-only in new viewport" is that the part or assembly is always turned in the direction of the system.

In the German user forum a Lisp was created that shows the selected part or assembly from the original direction.

Two options are available. Once the original size, the other with fit to window.

These commands can be put under two buttons and added to the Mini toolbar for single part + Several parts and assemblies.

If you choose in the structure browser a part or assembly, in the v18.1 this also open the Mini toolbar.

Click the button with fit to window and you have what you want.

Download the Lisp: http://osd.cad.de/lisp_3d_48.htm

PeterKehoe
5-Regular Member

Here is some LISP code that I wrote which does (I think) what you are asking for. It works very simplistically by remembering what you have in your drawlist, turning everything off excep the part or assembly you want to fit, then draws everything again.

;peter kehoe 18Mar2013

(in-package :hphb)
(use-package :oli)

(sd-defdialog 'fit_to_part
  :dialog-title "Fit to Part/Assy"
  :dialog-control :parallel
  :toolbox-button t
  :start-variable 'pick_part
  :variables
'((pick_part   :value-type :part-assembly
     :title "Part/Assy"
     :modifies nil
  )
(vport
           :value-type :viewport
           :multiple-items nil
           :title "Viewport"
           :initial-value (first (oli:sd-inq-vp-names))
    )
)
  :ok-action
'(let (drawlist)
  (setq drawlist (oli:sd-inq-vp-drawlist-objects vport))
  (sd-call-cmds (set_vp_drawlist vport :with-wp :vp-fit pick_part))
  (dolist (obj drawlist "done")
             (when obj
               (add_to_vp_drawlist vport obj)
   )
          )
)
)

DanAdler
12-Amethyst

Thanks Peter.  I haven't used custom LISP code before.  When you get a chance can you explain how I add this command to Modeling?

PeterKehoe
5-Regular Member

Dan,

Copy everything from "(in-package :hphb)" to the last ")" into a file. Save that file with a name like "fit_to_part.lsp". (The ".lsp" extension is helpful.) To test it, you can just drag-n-drop the file into a running Creo Elements/Direct Modeling session; it will add the new command to the "Toolbox".

fit_to_part..jpg

To add it permanently, you will have to modify your local customization file. The location of this file depends on what operating system you are using and what version of Creo Elements/Direct Modeling you are using. For example, if you are on Windows7 and version 17, the file would be C:\Users\<your login name>\AppData\Roaming\CoCreate\CoCreate Modeling 17.0\17.0\sd_customize. If that file doesn't exist, you will need to create it. Once you do, you can add a line to it to load that file. For example,

(load "C:\fit_to_part.lsp")

DanAdler
12-Amethyst

That's exactly what I'm looking for!  One last question... Is it possible to add this command to my ribbon?  I see that I can add the Toolbox Buttons to my ribbon which is a drop down menu but I cannot add a command from the Toolbox directly onto the ribbon.  No big deal if not just saves a click.  Thanks again!

FriedhelmK
17-Peridot

Hi Peter,
I tried your lisp
Works well when the desired part is in front of the Model
If it is behind the model, it is covered by other parts and you can not see it.

PeterKehoe
5-Regular Member

If the model is covered by other parts, there isn't an easy way to make it work. The only way to see it is to either turn everything else off (that capability already exists with "Draw Only"), or turn off parts between the selected part and the viewer. While it is possible to automatically turn off parts, determining which ones would be difficult. For example, would you want to turn off all parts that obscure even a small bit of the selected part? Or just enough that you can see a small bit of the selected part? And should the command keep track of which ones it turned off in case the user wanted to know that information? The only way that I can think of that would make this easy to use would be do the fit (as my code does) and then come up with a list of all parts that obscure the selected part. The user could then selectively turn those parts on/off to get the view that they want before exiting the command. This, however, is more work than I have time for at the moment.

PeterKehoe
5-Regular Member

Dan,

It took me a little while to find out how to add the command to a ribbon because I'm still using version 17. But I did find a way.

Assuming you have the command loaded automatically, go the File -> Customize. In the Customize menu, select New... Give the command a name (e.g. "Fit to Part"), and select a group (I used "Window").Press the Record button and then pick the command from the Toolbox. Press the Stop Command Recording button, then OK to complete the creation of your new command. Close the Customize window.

Now, once you have the new command defined, you can add it to the ribbon. Select File->Options to bring up the menu to Customize Ribbon. Make sure "Available Command Groups" is listed under "Choose commands from:". Below that, choose the group that you used for your command (i.e. "Window"). You should see the command name that you entered above. Now, find the group on the right side where you want to add the new command. For example, if you want to add it to the "Utilities" group in the Modeling tab, expand Modeling and select Utilities. Select your command name and then "Add>>" to add it to the selected group.

PTCModerator
Emeritus
Status changed to: Archived