PDA

View Full Version : How do I detect if a shared part is active


Peter Boks
12-16-2005, 03:01 AM
Hello all,

Does anybody know of a reliable and fast way, to detect if the active part is shared or not (in a macro).
The purpose for this is that I want the commandline to change color when a shared part is active. I thought that this would be easy with INQ_ENV or INQ_PART but that was a mistake. There seems to be no command for this (to my surprise).

Best regards,
Peter Boks

John van Doorn
12-18-2005, 09:44 AM
Hi Peter,

You can try the command:
parts_list tree ltab 'mypartslist'

This will tell you in a logical table which is the active part by " " and also if this part is a shared part.

John

Peter Boks
12-18-2005, 10:18 AM
Hi John,

Thanks for your suggestion but I have allready tried that. The problem is that we have drawings with close to 4000 parts. It takes 1.15 seconds to transfer the partlist into a logical table. Finding the row with "*" will probably take even longer. So unfortunately this routine takes to long if I want to work smoothly.

Regards,
Peter

Darren
12-19-2005, 12:57 AM
Hi Peter,

Do you wish to inquire if the active part is simply shared or actually used (copied) elsewhere?

/Darren

Peter Boks
12-19-2005, 01:28 AM
Hi Darren,

The goal is to have a strong visual on whether I am working in a shared part or a normal part.
If the part turns out to be shared, I want the commandline area to change color.
So just knowing if the part is shared will be sufficient.

Best regards,
Peter

Darren
12-19-2005, 02:16 AM
OK.

The simplest method works only if the part is shared and has been copied. In this situation I suggest that your macro does this:

1. Counts all (global) elements on your drawing
2. Draws a line in the active part
3. Counts the number of global elements and compares this with the first count.
4. If the difference is greater than 1 then you know that the part is shared AND copied.
5. Delete the new line.

This method will not tell you if the active part is shared if it hasn't been copied. To do this your macro will have to copy the active part first.

Let me know how you get on.

/Darren

Peter Boks
12-19-2005, 05:19 AM
Hi Daren,

Thanks for your input.
I have finished the macro, making use of your advise and it runs pretty smoothly. The fact that it doesn't change colors when only a single instance of the shared part exists, is no problem.

I have also embedded a routine that uses double click functionality for changing the active part (as we talked about some time ago).
The variable Madern_laatste_tijd must be defined outside the macro first, to make it global. Here it is:

DEFINE Madern_mousebutton_3_plain
LOCAL Old_time
LOCAL New_time
LOCAL P1
LOCAL Firts_count
LOCAL Second_count

LET Old_time Madern_laatste_tijd
LET New_time (TIME)
LET Madern_laatste_tijd New_time

IF ((New_time - Old_time)<Madern_dubbelkliktijd)
EDIT_PART PARENT
ELSE
EDIT_PART
READ PNT LAST_PROMPT LAST_FEEDBACK P1
EDIT_PART P1
END_IF
INQ_SELECTED_ELEM GLOBAL ALL
LET First_count (INQ 14)

ADD_CURRENT_INFO INFO_NAMESPACE 'Madern check shared part' 'DELETE ELEMENT'
LINE 0,0 10,10 END
INQ_SELECTED_ELEM GLOBAL ALL
LET Second_count (INQ 14)

IF ((Second_count - First_count) > 1)
CMD_BG_COLOR Bcol2
CMD_TXT_COLOR
BLACK
ELSE
CMD_BG_COLOR Bcol0
CMD_TXT_COLOR
WHITE
END_IF

DELETE NAMESPACE_INFOS 'Madern check shared part' 'DELETE ELEMENT' END
CHANGE_CURRENT_INFO INFO_NAMESPACE 'Madern check shared part' 'DELETE ELEMENT' ''
END_DEFINE

Best regards,
Peter

Peter Boks
12-19-2005, 07:10 AM
I have to make a small adjustment to the macro above.
The line with the READ command should look like this:

READ PNT STRING LAST_PROMPT LAST_FEEDBACK P1

to be able to pick a part in the partbrowser.


Regards,
Peter