change color on A-side by Ilogic.. Possible?

change color on A-side by Ilogic.. Possible?

Darkforce_the_ilogic_guy
Advisor Advisor
810 Views
8 Replies
Message 1 of 9

change color on A-side by Ilogic.. Possible?

Darkforce_the_ilogic_guy
Advisor
Advisor

I have some sheet metal part that I need to make more visible Which side is up.  Some material it matter whict side is up and down ... I want to make a code that remove the Texture form one of the side.  Is there a way to do this ? 

 

I can´t name surface sind there are no Surface the templet Metal sheet file. that why I was thinking about using the A-side.  but I like the option of remove form the other side then the A-side as well if possible 

0 Likes
811 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  Here is some iLogic code you can play around with.  It accesses the A-Side Face of the active sheet metal part, if one has been defined.  Then it is simply attempting to set the first appearance found in the part as the appearance of that face.  But you can change which appearance you set to it.  Just remember that the appearance Asset object you want to assign to the face, needs to be a 'local' copy that is saved in the document, not just a library appearance.

If ThisDoc.Document.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	MsgBox("This is not a Sheet Metal Part. Exiting rule.", vbCritical, "")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
If oSMDef.ASideDefinitions.Count = 0 Then
	MsgBox("There are no 'A-Side Definitions in this part.", vbCritical, "")
	Exit Sub
End If
Dim oASideDef As ASideDefinition = oSMDef.ASideDefinitions.Item(1)
Dim oAFace As Face = oASideDef.ASideFace
'get/specify appearance type Asset to supply as value to face appearance
Dim oAppAsset As Asset = oPDoc.AppearanceAssets.Item(1)
oAFace.Appearance = oAppAsset
'oAFace.AppearanceSourceType = AppearanceSourceTypeEnum.kOverrideAppearance

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 9

Darkforce_the_ilogic_guy
Advisor
Advisor

the code work fine to remove any Surface, but  I need to add a color.. Maybe to somthing like picture 2 :)..

 

Second thing.  when made a flat Pattern.. it does not add an A-side ever when it still  have kind of a A-side... any change that it can make it work on the undefine A-side as well ?

bt_0-1668578885704.png

bt_1-1668578907300.png

 

0 Likes
Message 4 of 9

GosponZ
Collaborator
Collaborator

Even if part is flat assign A side (and even flat pattern) in drawing you will have good side up. I allways do A side and never had any problem 

Message 5 of 9

WCrihfield
Mentor
Mentor

Hi @Darkforce_the_ilogic_guy.  Here is something you can try out.  It first checks to see if any true 'A-Side' face has been defined, and if not, it then checks the FlatPattern for its 'BaseFace'.  You can set this when creating a flat pattern initially, but if you do not specify one, one is set for you automatically, so I believe it will always have a value.  I believe the FlatPattern.BottomFace will always have a value too, but it seems to me like I have encountered situations where there was no value for the FlatPattern.TopFace, so I did not include that as a possibility.  Also, this version attempts to get a standard appearance from the 'Inventor Material Library' named "White", then checks to see if there is a local copy of it, and if not, it creates a local copy of it for use when setting the appearance to the face.  I don't know if something like that is what you had in mind, but it seemed more realistic than simply getting the first appearance in the document to use for the face, so that's what I went with for this example.

If ThisDoc.Document.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	MsgBox("This is not a Sheet Metal Part. Exiting rule.", vbCritical, "")
	Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
Dim oFaceToChange As Face = Nothing
If oSMDef.ASideDefinitions.Count > 0 Then
	oFaceToChange = oSMDef.ASideDefinitions.Item(1).ASideFace
End If
If IsNothing(oFaceToChange) Then
	'try to get the 'BaseFace' from the FlatPattern
	Dim oFP As FlatPattern = Nothing
	If oSMDef.HasFlatPattern Then
		oFP = oSMDef.FlatPattern
	Else
		Try
			oSMDef.Unfold
			oFP = oSMDef.FlatPattern
			oFP.ExitEdit
		Catch
			MsgBox("Error unfolding part to get FlatPattern.", vbCritical, "")
			Exit Sub
		End Try
	End If
	If IsNothing(oFP) Then Exit Sub
	oFaceToChange = oFP.BaseFace 'usually the stationary face when others unfold
	'oFaceToChange = oFP.BottomFace
End If
'get/specify appearance type Asset to supply as value to face appearance
Dim oInvMatLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Inventor Material Library")
Dim oWhite As Asset = oInvMatLib.AppearanceAssets.Item("White")
'get a 'local copy' of this appearance to work with (needed)
Dim oDocApps As AssetsEnumerator = oPDoc.AppearanceAssets
Dim oAppAsset As Asset = Nothing
Try
	oAppAsset = oDocApps.Item("White")
Catch
	oAppAsset = oWhite.CopyTo(oPDoc, True)
End Try
oFaceToChange.Appearance = oAppAsset
'oFaceToChange.AppearanceSourceType = AppearanceSourceTypeEnum.kOverrideAppearance

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 9

Darkforce_the_ilogic_guy
Advisor
Advisor

our problem is that we have some materiel like Alu floor plate with some kind of pattern on them, so it is very importen that both the person who drawing the sheet metal and the person that later make the plate know with side on the plate is the side with the pattern... to make it easy for both the User and the plate maker . I want to do somthing to remove the pattern from the 3d file and that way also remove it from the drawing without the guy who draw the drawing need to remember doing it.  and make it visible under construction

0 Likes
Message 7 of 9

Darkforce_the_ilogic_guy
Advisor
Advisor

you code work fine .. but I would like to make it  reset the old A.side back to normal color, if the user change the A-side. you have any ide for that as well ?

0 Likes
Message 8 of 9

Darkforce_the_ilogic_guy
Advisor
Advisor

am I the only one that have problem with coming into the forum ? I can´t get to it the normal why .. and can´t start new post ...my computer say that there are no post ... and when I force it to start a post ... It can´t select with forum to write it in... I try to contact the forum in this old post

0 Likes
Message 9 of 9

WCrihfield
Mentor
Mentor

I am hearing that lots of others are also having lots of odd problems too, so you are not alone.  I hear that the problem is being looked into, but it can be difficult to pinpoint.  Here is a link to the community feedback forum, where some of this has been posted about.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes