Two questions about scripts I would find useful.

Next
 From:  fcwilt
11696.1 
Hi,

1. Could a script be written to delete all unused styles?

2. Could a script be written to consolidate duplicate styles, possibly near-duplicate styles? When importing step files it's not uncommon to get lots of styles that could be consolidated.

Thanks.

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.2 In reply to 11696.1 
Hi Frederick,

re:
> 1. Could a script be written to delete all unused styles?

There's a script in this thread:
https://moi3d.com/forum/index.php?webtag=MOI&msg=3774.1


re:
> When importing step files it's not uncommon to get lots of styles that
> could be consolidated.

Can you post an example file?

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
11696.3 In reply to 11696.1 
Hi Frederick,

When I import a STEP file I consolidate the styles by selecting the imported STEP and then click on the color swatch of the Default style to assign the whole thing to the default style.

An even cleaner way is to open the STEP in its own window, assign the style there, and then copy-paste it into the window I'm actually working in. That avoids having all the STEP styles pollute my list of styles.

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.4 In reply to 11696.3 
Hi,

Yes that does solve the problem in one sense but I lose all the different colors which make dealing with the import easier, at least for me.

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.5 In reply to 11696.2 
Hi Michael,

I deleted both of the objects that were imported, leaving just the styles.

But in some cases I might have several imports and the number of styles just keeps growing.

As to "matching" styles I was thinking it would be good if "similar' styles could be consolidate. Deciding what "similar" means could be difficult.

In the "real world" the objects would be retained and the consolidated styles would be applied as appropriate.

Thanks.

Frederick

EDITED: 7 Apr by FCWILT


  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.6 In reply to 11696.5 
Hi Frederick, what is your desired result from running the script on your example?

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.7 In reply to 11696.5 
Hi Frederick, try this attached script. It will get rid of 40 styles on your example file.

It merges styles that are close to the same color. If doing it by only merging the exact same colors there would be only 5 removed in your example file.

- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.8 In reply to 11696.7 
Hi Michael,

You are the best.

I will test that script ASAP.

Thanks.

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.9 In reply to 11696.7 
Hi Michael,

It works wonderfully well.

Thanks very much.

The style names (LEVEL###) that result from importing the step files mean little.

If I were to write a script that correctly re-sequenced them (1, 2, 3, etc.) would that break anything?

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.10 In reply to 11696.9 
> If I were to write a script that correctly re-sequenced them (1, 2, 3, etc.)
> would that break anything?

No I don't think so.

If you want to use a "Search and replace" on style names there is a script here that can help with that:
http://moi3d.com/forum/index.php?webtag=MOI&msg=10416.2

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.11 In reply to 11696.10 
Hi Michael,

I was able to write a script that re-sequenced the "Level ###" style numbers and it seems to work fine.

BUT running the script against 72 styles took far longer than I expected, 58 seconds.

IF I delete all of the objects the script took a second or two BUT I need the objects to remain.

So two questions:

1. Is there a means to change the cursor to the typical "busy' cursor? And change it back, or course.

2. Is there a means to trace code execution via some built-in "logging" system that messages could be written to?

Thanks.

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.12 In reply to 11696.11 
Hi Frederick,

re:
> I was able to write a script that re-sequenced the "Level ###" style numbers and it seems to work fine.
>
> BUT running the script against 72 styles took far longer than I expected, 58 seconds.

Can you post the script?


> 1. Is there a means to change the cursor to the typical "busy' cursor? And change it back, or course.

There is not currently a way to do that by script, sorry.


> 2. Is there a means to trace code execution via some built-in "logging" system that messages
> could be written to?

Threre is a log you can write to by: moi.ui.log( msg ).to view log, use: moi.ui.createDialog( 'ShowLog.htm' );"

-0 Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.13 In reply to 11696.12 
Hi Michael,

Attached is my first cut at the script to re-sequence the style names.

As to the cursor - is that something that could be added to V5?

Thanks for the info regards the log file - just what I was looking for.

Frederick

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.14 In reply to 11696.11 
Hi Frederick, I tried your StylesReSequenceLevels script on the "TWO STEP IMPORTS FOR SHOWING STYLES.3dm" file and it is only taking less than 1 second to run it.

Can you post the file where it takes 58 seconds?


> As to the cursor - is that something that could be added to V5?

Yes, I've added it for the next v5 beta as: moi.ui.setBusyCursor( busy );

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.15 In reply to 11696.14 
Hi Michael,

Good news on the cursor issue.

As to the file, even zipped it is appx 64 MB.

It's the objects that are slowing the script.

If I remove ALL of the objects it only takes a second or two to run the script.

My download limit is reported as being 50 MB - can you temporarily increase it for uploading this one file?

Or I could post the links to the two step files that I imported for testing the script.

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.16 In reply to 11696.15 
Hi Frederick,

re:
> Or I could post the links to the two step files that I imported for testing the script.

Could you please post the links or e-mail them to me at moi@moi3d.com?

But yeah if it's when you have several hundred MB of objects some things like storing undo information can become time consuming.

Taking 1 minute to process a heavy amount of objects is not particularly unexpected. It might be possible to tune it up though.

Thanks,
- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  fcwilt
11696.17 In reply to 11696.16 
Hi Michael,

Here are links to a couple of step files that may show the problem with large number of objects:

https://github.com/bigtreetech/HermitCrab/blob/master/HermitCrab2/3D/BIGTREETECH%20Hermit%20Crab%202%20CAN%20V1.0.zip

https://grabcad.com/library/btt-hermit-crab-v2-canbus-1

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
11696.18 In reply to 11696.17 
Hi Frederick, the delay is from generating undo records for object style assignments on every name change.

You can avoid that from happening if you bracket your style modification loop with moi.geometryDatabase.styleEditorOpened(); / moi.geometryDatabase.styleEditorClosed(); like in the attached version.

With that in place it will only generate the undo record one time and should be much faster.

- Michael

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  fcwilt
11696.19 In reply to 11696.18 
Hi Michael,

I was going to ask if there was a way to disable the collection of undo information - and it turns out there is.

Thanks.

Frederick
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All