More then on imate with ilogic suppress

More then on imate with ilogic suppress

jletcher
Advisor Advisor
1,309 Views
16 Replies
Message 1 of 17

More then on imate with ilogic suppress

jletcher
Advisor
Advisor

Is there a way to put a bunch of imates under one line code?

 

 I have imate iInsert:1 thru iInsert:49 I need them all suppressed when an event happens.

 

 I can get it to work one by one but that would be a lot of code.

 

Tried a few other thing but seems not to work.

 

 Thanks for the help..

0 Likes
1,310 Views
16 Replies
Replies (16)
Message 2 of 17

Anonymous
Not applicable

Hope this will help you

 

Dim oPart As PartDocument
    Set oPart = ThisApplication.ActiveDocument
    
    Dim oiMate As iMateDefinition
    For Each oiMate In oPart.ComponentDefinition.iMateDefinitions
        oiMate.Suppressed = True
    Next

 

Message 3 of 17

jletcher
Advisor
Advisor

This issue with that is it will do them all. I need to suppress like 10 of them but 10 others have to un-suppressed.

 

 I have no problem suppress all but I do like your code better then mine for that.

 

 Thanks for the help.. Maybe you know the other way I need?

0 Likes
Message 4 of 17

pball
Mentor
Mentor
Try using his code and adding a if to check the name of the imate. I don't have time to make some real code but I can explain what I mean with sudo-code.

For Each oiMate In oPart.ComponentDefinition.iMateDefinitions
number = 'parse number from imate name
if (number >= 1) and (number <= 49) then
oiMate.Suppressed = True
end if
Next

That should work as long as all the imates you want to change are numbered sequentially. Though I have another idea if you need to do randomly named imates. If you'd like an example of that let me know.
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
Message 5 of 17

jletcher
Advisor
Advisor

Pball

 

  With his code and your code it does work. 

 

   But I guess I did not think it all the way.

 

 By doing this it bypasses the auto suppression and auto un-suppression. So if I am only using 2 holes all the imates turn on even if there is no hole (strange it did not error in some way).

 

 Try to explain.

 

 I have 20 holes in the part not all holes will be used I may need only 1 or 2 at a given point or all 20 at another. For imate this was no issue because it would suppress the imate when the hole was suppressed and when the hole was used it would un-suppress the imate.

 

 But when I do opposite only or make opposite they error because the holes are used but the imate does not suppress or move with the mirror or opposite part.

 

 

  There may not be a way to handle that I guess.

 

 Might just have to add every imate to the hole code. I was hoping not but what is a few hundred lines of code but time right?

 

 But I can use the code for the opposite  because that is still needed..

 

 I will give kudos to both for the help...

 

 Time to start coding.....

 

 

 

0 Likes
Message 6 of 17

jletcher
Advisor
Advisor

Ok maybe I can't use it it will not turn them back on after I un-select opposite..

 

 If I put code in to turn them back on all turn back on not just the ones needed. Again no error and I don't understand why there is no hole for it..

 

 I will play with it..

0 Likes
Message 7 of 17

jletcher
Advisor
Advisor

OK was able to get it to error the other imates I guess I had to close the form for the error to happen.

 

Have not looked into code to handle it yet.

 

 If I go back to my form turn a hole on and apply the imates in error fix themselves. Then I have to turn the hole back off.

 

 Not good..

 

 I will play some more and keep you informed.

0 Likes
Message 8 of 17

jletcher
Advisor
Advisor

Well I guess I am not smart enough in the ilogic area yet.

 

 I don't think I can do this I tried to add code to every hole without thinking (only did 4) but the hole will always be true also in the opposite part so adding it to the holes did not work.

 

 I may just have to to them out till I can figure it out if it can even be done,,

 

 Wish the imate would mirror then my issues would not be issues..

0 Likes
Message 9 of 17

jletcher
Advisor
Advisor

OK update..

 

 

 The code you two helped with does not work but does work LOL.

 

 It does suppress them but they still error out just not in the browser see pic..

 

error imate.JPG

 

 

When testing I was only looking at the browser for the error when I went to save I seen the red cross and as you can see they do error still but not in browser..

 

 Oh well I guess I will have to take them out..

0 Likes
Message 10 of 17

xiaodong_liang
Autodesk Support
Autodesk Support
Hi jletcher,

I tested with saseendrankombath's code in the message 2 on a simple part which has some iMates. It works well. I did not receive the error you hit. Could you share a demo part and the code you are running?

0 Likes
Message 11 of 17

jletcher
Advisor
Advisor

Did you read all post of mine or just tried his code? His code works fine until you uncheck opposite then errors out.

 

I already deleted all imates and removed code because it does not work.

 

Can you upload your part so I can see your code maybe I had something wrong I just don't have time to redo everything and it not work again. I had to move on to next part.

 

 

 

 

 

 

 

0 Likes
Message 12 of 17

xiaodong_liang
Autodesk Support
Autodesk Support
Hi James,

I missed your comment in the the message. What I tested with is a very simple part (no hole). Sorry, I did not get the big picture of your part (with the holes and iMate controls them). Could you upload a small demo? I can take a look what I can figure out.
0 Likes
Message 13 of 17

Anonymous
Not applicable

I am using the same code in my addins and macros to suppress and un suppress the imates with more than 100 holes with imates in multibody parts. and the same imates are used for the derived parts (with mirror) from the multibody by deriving and used to suppress and un suppress without any error.

0 Likes
Message 14 of 17

jletcher
Advisor
Advisor

Saseendrankombath,

 

   Not sure how yours is working but that's great.. But tell me how did you mirror the imates as far as I know this cannot be done.

 

  Here is some pics of the errors and the part I guess I did not delete them I thought I did.  I did not put the imates on the mirror part because I can't get it to work with the other holes 1st.

 

 Error 1.JPG

 

Error 2.JPG

 

Error 3.JPG

0 Likes
Message 15 of 17

jletcher
Advisor
Advisor

Just start the form and click opposite only (LOL just seen I misspelled it I will fix that LOL) Then apply close form no errors but look up at the red cross and you can see they do error.

 

 Now go back in the form un-check the opposite and apply and you can see they error out again because it turns on the ones that have the hole turned off.

 

 This you can fix by turning on a hole and apply it.

 

 

 

0 Likes
Message 16 of 17

Anonymous
Not applicable

I used to create the iMate (using an Addin to create imate automatically based on hole type)with export option in the Base Part where the holes are done . Derive the part in to a blank part with mirror option. derive all the corresponding imates for the mirror part(again using an addin to do the same). The iMates will be in Place. You can use both the parts in an assembly and all the iMates can be used.

0 Likes
Message 17 of 17

Anonymous
Not applicable
0 Likes