CoCreate User Forum  

Go Back   CoCreate User Forum > Support > Customization

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 09-02-2014, 11:15 PM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
Lisp - select all unique models in session??

Hi,

I know 2 tricks for "doing something with all parts and assy's in session":
- take the top assy and run through all children with this famous piece of Lisp code:
Code:
(defun jb-inq-obj-tree-list (obj)
  	(cons obj
   		(apply #'nconc 
			(mapcar #'jb-inq-obj-tree-list 
				(sd-inq-obj-children obj)
			)
		)
	)
)
- use a select-trick like this:
Code:
(setf tot (sd-call-cmds (get_selection :focus_type (list *sd-part-seltype* *sd-assembly-seltype*) :allow_wire_part :allow_face_part :allow_graphics_only (list :part :assembly) :select :recursive :all_at_top)))
But both these methods will include all instances (Shares) of each part/assy. We have assemblies with 5000+ parts, but only appr. 1000 unique parts. Our lisp routine is slow now (1 minute), and we imagine that it would be much faster if we would use a command that selects only 1 instance per unique part/assy.
Does a trick like that exist???
Thanks!
Jaap
Reply With Quote
  #2  
Old 09-04-2014, 12:26 PM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: Lisp - select all unique models in session??

Rough idea: Walk the tree and insert part/assemblies into a hash table, using their contents data as the key. The resulting hash table would then contain only unique parts/assemblies.
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/
Reply With Quote
  #3  
Old 09-04-2014, 12:52 PM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
Re: Lisp - select all unique models in session??

Thanks Claus,

We'll take a dive into the hashtable manual :-)
Jaap
Reply With Quote
  #4  
Old 09-04-2014, 01:02 PM
clausb's Avatar
clausb clausb is offline
Registered User
 
Join Date: Nov 2002
Posts: 1,168
Re: Lisp - select all unique models in session??

Untested sketch of how to insert a part/assy object into a hash table which uses the contents ID as the key:

(setf (gethash (sd-inq-obj-contents-sysid object) hash-table) object)
__________________
CoCreate Modeling FAQ: http://www.clausbrod.de/CoCreateModeling/
Reply With Quote
  #5  
Old 09-04-2014, 04:05 PM
Andy Poulsen Andy Poulsen is offline
Administrator
 
Join Date: Apr 2003
Location: Fort Collins, Colorado
Posts: 273
Re: Lisp - select all unique models in session??

Quote:
Originally Posted by clausb View Post
Untested sketch of how to insert a part/assy object into a hash table which uses the contents ID as the key:

(setf (gethash (sd-inq-obj-contents-sysid object) hash-table) object)
Then when you're finished with putting the list into the hash table, just iterate over the hash table using maphash or one of the other methods. Should be pretty fast!

Good luck!

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
  #6  
Old 09-04-2014, 09:23 PM
jkramer's Avatar
jkramer jkramer is offline
Registered User
 
Join Date: Oct 2002
Location: the Netherlands
Posts: 382
Re: Lisp - select all unique models in session??

Great, thanks for the suggestions!!
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 03:23 PM.



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: