ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why do the RealDWG docs say that some functions are not applicable "Due to the graphics dependency of the AcDbSubentId"?

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
tbrammer
318 Views, 3 Replies

Why do the RealDWG docs say that some functions are not applicable "Due to the graphics dependency of the AcDbSubentId"?

The ObjectARX docs state this for various functions that use AcDbSubentId:

"Due to the graphics dependency of the AcDbSubentId object, this function is not applicable for the RealDWG SDK."

I.e. for:

  • AcDb3dSolid::filletEdges(const AcArray<AcDbSubentId *> & edgeSubentIds,...)
  • AcDb3dSolid::setSubentColor(const AcDbSubentId & subentId, const AcCmColor & color)
I tried the code below with RealDWG and it worked perfectly. It creates an AcDb3dSolid box, recolors faces and edges and creates a fillet for the edges around one face.
Could it be that this statement is outdated? Or are there really any restrictions regarding AcDbSubentId in RealDWG? I can't see any reason for that. in my test the AcDbSubentIds had unique Adesk::GsMarkers. So, they should work perfectly to identify subentities.
 
void cmdTestBrep()
{
	Acad::ErrorStatus es;
	AcDbDatabase *db = new AcDbDatabase();
	AcDb3dSolid *solid = new AcDb3dSolid;
	solid->setDatabaseDefaults(db);
	es = solid->createBox(200.0, 300.0, 400.0);
	AcDbObjectId idSolid;
	es = PostToDb(db, idSolid, solid);

	AcBrBrep *pBrep = new AcBrBrep();
	AcDbFullSubentPath adfsp(idSolid, kNullSubentId);
	AcBr::ErrorStatus ebs = pBrep->setSubentPath(adfsp);

	AcBrBrepFaceTraverser faceTraverser;
	ebs = faceTraverser.setBrep(*pBrep);
	assert(ebs == AcBr::eOk);

	std::vector<Face2Edges> facePathToEdgePaths;
	AcBrFace face;
	AcDbFullSubentPath subFacePath, subEdgePath;

	for (ebs = faceTraverser.restart(); !faceTraverser.done(); ebs = faceTraverser.next())
	{
		ebs = faceTraverser.getFace(face);
		if (ebs == AcBr::eOk)
		{
			ebs = face.getSubentPath(subFacePath);
			if (ebs == AcBr::eOk)
			{
				Face2Edges f2es;
				f2es.face = subFacePath;				

				AcBrFaceLoopTraverser faceLoopTrav;
				ebs = faceLoopTrav.setFace(face);
				for (; !faceLoopTrav.done(); ebs = faceLoopTrav.next())
				{
					AcBrLoop loop;
					ebs = faceLoopTrav.getLoop(loop);
					if (ebs == AcBr::eOk)
					{
						AcBrLoopEdgeTraverser loopEdgeTrav;
						ebs = loopEdgeTrav.setLoop(loop);
						for (; !loopEdgeTrav.done(); ebs = loopEdgeTrav.next())
						{
							AcBrEdge edge;
							ebs = loopEdgeTrav.getEdge(edge);
							if (ebs == AcBr::eOk)
							{
								ebs = edge.getSubentPath(subEdgePath);
								if (ebs == AcBr::eOk)
									f2es.edges.append(subEdgePath);
							}
						}
					}
				}
				facePathToEdgePaths.push_back(std::move(f2es));
			}
		}
	}

	delete pBrep;

	// recolor the faces
	if ((es = acdbOpenObject(solid, idSolid, AcDb::kForWrite)) == Acad::eOk)
	{
		AcCmColor color;
		Adesk::UInt16 colorIndex = 0;
		
		for (const Face2Edges & f2es : facePathToEdgePaths)
		{
			color.setColorIndex(++colorIndex);
			es = solid->setSubentColor(f2es.face.subentId(), color);
		}

		static double dRadius = 10.0;
		static double dSetbackStart = 0.0;
		static double dSetbackEnd = 0.0;

		for (const Face2Edges& f2es : facePathToEdgePaths)
		{
			int count = f2es.edges.length();
			if (count>0)
			{
				AcArray<AcDbSubentId> edgeIds;
				AcArray<AcDbSubentId*> edgeIdPtrs;
				AcGeDoubleArray startSetback, endSetback, radius;
				edgeIds.setLogicalLength(count);
				edgeIdPtrs.setLogicalLength(count);
				radius.setLogicalLength(count);
				startSetback.setLogicalLength(count);
				endSetback.setLogicalLength(count);
				for (int i=0; i<count; ++i)
				{
					color.setColorIndex(++colorIndex);
					es = solid->setSubentColor(f2es.edges[i].subentId(), color);

					const AcDbFullSubentPath& path = f2es.edges[i];
					edgeIds[i] = path.subentId();
					edgeIdPtrs[i] = &(edgeIds[i]);

					radius[i] = dRadius;
					startSetback[i] = dSetbackStart;
					endSetback[i] = dSetbackEnd;
				}

				es = solid->filletEdges(edgeIdPtrs, radius, startSetback, endSetback);

				break;
			}
		}

		solid->close();
	}


	db->saveAs(L"c:\\temp\\brep.dwg");
	delete db;
}
 

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

3 REPLIES 3
Message 2 of 4
m_latz
in reply to: tbrammer

I would agree with you that not everything that is written in the documentary of RealDWG is always correct.

 

But have you tested your example on a computer that really only has the "runtime environment", not the "developer environment" of RealDWG installed and no other autodesk products ?

 

regards

 

Markus

Message 3 of 4
tbrammer
in reply to: tbrammer

I don't think that my RealDWG app would use any modules from an existing AutoCAD installation and invoke it's GS functions.  Anyway, I ran my test app together with "Process Monitor" snooping for access to paths beginning with "C:\Program Files\Autodesk\AutoCAD". It didn't find any. All accesses have been made to paths starting with "C:\Program Files\Autodesk\RealDWG".

 

In the meantime I asked this directely to the ADN DevSup. Let's see what they respond.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 4 of 4
tbrammer
in reply to: tbrammer

I asked this question to the Autodesk Developer Support. 

They confirmed that the statement is obsolete. These function can be used in RealDWG.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost