Closed lijiayi0921 closed 2 years ago
@lijiayi0921 It isn't obvious looking at your code that you are doing anything wrong. Please give me some time to attempt this myself and reply with some sample code.
@jchick-bentley thanks a lot!
@lijiayi0921 Please see my example below. Hope this helps. Please let us know if you have any other questions.
export const Component: pcf.ElementDMO = {
irEntity: "Component",
ecElement: {
name: "Component",
baseClass: "BisCore:PhysicalElement",
},
modifyProps(props: any, instance: pcf.IRInstance) {
const builder = new GeometryStreamBuilder();
// props has category given categoryAttr is defined.
const params = new GeometryParams(props.category);
params.weight = 10;
builder.appendGeometryParamsChange(params);
const length = 40000;
const width = 30000;
const height = 10000;
const baseOrigin = new Point3d(0,0,0);
const vectorX = new Vector3d(1,0,0);
const vectorY = new Vector3d(0,1,0);
const topOrigin = new Point3d(0,0,height);
const baseX: number = length;
const baseY: number = width;
const topX: number = length;
const topY: number = width;
const capped: boolean = true;
const myBox = Box.createDgnBox(baseOrigin, vectorX, vectorY, topOrigin, baseX, baseY, topX, topY, capped);
builder.appendGeometry(myBox);
props.geom = builder.geometryStream;
},
categoryAttr: "Space",
doSyncInstance(instance: pcf.IRInstance) {
if (instance.get("Space").includes(","))
return false;
return true;
},
};
@jchick-bentley Thanks for the example !
However there is still nothing in the model, as it says "This iModel has no data to view". I took the example from here
When I implemented your component definition, I got the error "Error | itwin.pcf | Cannot read property 'length' of undefined", at this line :
const params = new common.GeometryParams(props.category);
I replaced props.category by (instance as any).category and it passes.
The generated model has nothing in the scene, whie the tree looks like this:
Does the target model need to have something, in order for this to work ?
@lijiayi0921
I also see the "This iModel has no data to view" alert and I also find it confusing. I raised the question to our Design Review team and will let you know their answer. For now, let's ignore it.
The fact that category property is undefined for you should be investigated - when I clone the COBie connector sample and run it with my modifications, I don't see this.
In the code I shared,
categoryAttr: "Space", doSyncInstance(instance: pcf.IRInstance) { if (instance.get("Space").includes(",")) return false; return true;
In the code you shared, I see ...
modifyProps(props: any, instance: pcf.IRInstance) { // modify default props assigned to current EC Entity props.userLabel = instance.key; props.geom = createBoxGeom(Point3d.create(1, 1, 1)); }, categoryAttr: "CategoryName", };
Is "CategoryName" really the category you want to use?
To debug this, you can set a breakpoint in Node.js at line 269 where the assignment props.category = categoryId; This assignment needs to be made upstream from your Component.modifyProps method in Element.js
I attached some screen grabs below to show what it looks like and what you can watch for in your watch window. The first screen grab is elementNode._update in Node.js.
If none of the above helps, can you tell me if you are running the COBie connector sample, a modified version of it or your own connector based on the COBie sample? Are there other details you can provide that you think would help me help you?
Hi @jchick-bentley
Thanks to your help with the debugger, I found the problem :
While I am using the latest version of @itwin/pcf (0.2.0-2), the example I took from here did not follow.
More specifically, the signature of modifyProps has changed from
modifyProps(props: any, instance: pcf.IRInstance)
to
modifyProps(pc: PConnector, props: any, instance: pcf.IRInstance)
With that problem solved, I managed to add the box into an empty scene.
Many thanks for taking time for my questions ! Jiayi
Hi,
This is a copy of this issue on iTwin/pcf. I did not get any answer so I think here may be a better place.
I'm trying to insert geometries into an empty iTwin model. Inspired by the example I try to draw some boxes. The connector program passes, changes are made in the iModel. A new named version is then created with the last change. But when opened it says "This iModel has no data to view". Elements can be found in the tree, but nothing is in the 3D view.
Below is my implementation.
What did I do wrong ? Thank you in advance