You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to export colours from existing autocad drawing.
I have read everything I can find about setting colours.
Previously exported IFC files have working colour information.
I am able to add the colour information but have not found the way to attach the shape definition to the StyledItem.
Thank you.
Assemblies and versions affected:
_Xbim.Essentials v4.0.30319
Steps (or code) to reproduce the issue:
A simple set of steps to reproduce the issue. Provide a small sample file is required and/or
a small sample of the failing code (or reference a commit / gist)
internalvoidUpdateColour(stringpartNo,Colorcolor){//need to add to Assignments(HasAssignments showing in template model)//add to Associations(HasAssociations "")using(vartxn= model.BeginTransaction(partNo+" colour update")){IfcBuildingElementbeam=(IfcBuildingElement)GetBeamFromACAD(partNo, model);if(beam!=null){// Create a presentation style assignmentvarpresentationStyleAssignment= model.Instances.New<IfcPresentationStyleAssignment>(psa =>{// Create a surface stylevarsurfaceStyle= model.Instances.New<IfcSurfaceStyle>(ss =>{ ss.Side = IfcSurfaceSide.BOTH;// or .POSITIVE or .NEGATIVE ss.Styles.Add(model.Instances.New<IfcSurfaceStyleShading>(sss =>{// Create a color (you might need actual RGB values) sss.SurfaceColour = model.Instances.New<IfcColourRgb>(c =>{ c.Name ="YourColorName"; c.Red =(double)color.Red /255; c.Green =(double)color.Green /255; c.Blue =(double)color.Blue /255;});}));});// Add the surface style to the presentation style assignment psa.Styles.Add(surfaceStyle);});// Create a styled itemvarstyledItem= model.Instances.New<IfcStyledItem>(si =>{// You can also create a specific representation item here if needed si.Styles.Add(presentationStyleAssignment); si.Name ="YourStyledItemName";});// Set the product representation for the beamvarbReps= beam.Representation.Representations;varshapeRepresentations= bReps.OfType<IfcShapeRepresentation>();// Output information about each IfcShapeRepresentationforeach(var shapeRepresentation in shapeRepresentations){//var type = shapeRepresentation.GetType(); varshape= shapeRepresentation.Items[0];varmodelContext= model.Instances.OfType<IfcGeometricRepresentationContext>().FirstOrDefault();}/* * /Create a Definition shape to hold the geometry var shape = model.Instances.New<IfcShapeRepresentation>(); var modelContext = model.Instances.OfType<IfcGeometricRepresentationContext>().FirstOrDefault(); shape.ContextOfItems = modelContext; shape.RepresentationType = "SweptSolid"; shape.RepresentationIdentifier = "Body"; shape.Items.Add(body); */
txn.Commit();
model.SaveAs(fileName);}}}
Colour would be applied to all objects referenced
the lines below are from the working file I have been provided
#10=IFCPRESENTATIONSTYLEASSIGNMENT((#11));
#11=IFCSURFACESTYLE($,.BOTH.,(#12));
#12=IFCSURFACESTYLESHADING(#13,$);
#13=IFCCOLOURRGB('ff7aafdf',0.47843137254902,0.686274509803922,0.874509803921569);
#14=IFCSTYLEDITEM(#15,(#10),$);
#15=IFCEXTRUDEDAREASOLID(#16,#19,#9,1075.);
line #14 includes a reference to item #15 which is how I assume the IfcStyledIem is being applied to the IFCEXTRUDEDAREASOLID.
Is this the correct method for IFC4?
If so is there a command to apply this information?
Actual behavior or exception details:
IfcStyledItems not associated with IFCEXTRUDEDAREASOLID
The text was updated successfully, but these errors were encountered:
I am trying to export colours from existing autocad drawing.
I have read everything I can find about setting colours.
Previously exported IFC files have working colour information.
I am able to add the colour information but have not found the way to attach the shape definition to the StyledItem.
Thank you.
Assemblies and versions affected:
_Xbim.Essentials v4.0.30319
Steps (or code) to reproduce the issue:
A simple set of steps to reproduce the issue. Provide a small sample file is required and/or
a small sample of the failing code (or reference a commit / gist)
Minimal file to reproduce the issue:
P0042_01_4x0.zip
Expected behavior:
line #14 includes a reference to item #15 which is how I assume the IfcStyledIem is being applied to the IFCEXTRUDEDAREASOLID.
Is this the correct method for IFC4?
If so is there a command to apply this information?
Actual behavior or exception details:
IfcStyledItems not associated with IFCEXTRUDEDAREASOLID
The text was updated successfully, but these errors were encountered: