Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

web.link drawing/view dimensions

DataJett

New member
Hello ALL,


I am having major issues with the web.link javascript wrapping of jlink. I have
written java for jlink & workflows, jsp/webject for windchill, but the
javascript wrapped around jlink is causing me issues.


I have done jlink in the past, but have had environment issues with wf2/3 &
switched to web.link for ease.


The tool I am trying to create is a program to place symbols on drawing
dimensions (probably created, not shown). Then write the dim|+tol|-tol|ad# etc
to a file (text 1st, then maybe excel).


I am learning all the limitations about offset of symbol. Getting the tol's of
drawing dims, etc. But I am learnind alternate routes for those.


The part that has me puzzled is the javascript code to gather the drawings dims.
Not the model dims. There are good
samples for that.


Per a ptc Tan-132460, I have learned that I need to obtain drawings views, then
gather my dims:


"When using ModelItemOwner.ListItems() to list all ITEM_DIMENSIONs in a view,
the returned objects are actually Dimension2D objects".


From the web.link docs, I have seen where they specify:
pfcModelItemOwner.ListItems() & ITEM_DIMENSION for type.


But I have tried every possible casting scenario & no go.


I either get typical type errors or "automation server can't create object".
Even though that error leans towards ActiveX & browser settings (which I have
checked over & over), I only get that error when dealing with the "ListItems"
or that area.


But I would appreciate any snippets or advice. But the docs give advice, so
snippets will help more. I would even appreciate jlink code, since I can
probably transfer to web.link code.


Thanks in advance for any help....


L. Jett
[email protected],[email protected]
 
Hello

I got no responses from this forum, but I did from ptcuser.org & here is an update:

Hello

Thanks for the responses (email or forum). I got a call back form ptc & here is the code that shows dims in drawing:

var dims = drawing.ListItems (pfcCreate ("pfcModelItemType").ITEM_DIMENSION);

Im not the greatest with jscript or java, but I thinkpfcModelItemType is a mthod off of pfcModelItemOwner
& thats what the Tan mentioned Owner.

But that code only helps you find dimensions that are owned by the drawing, which is not default for most proe
environments. Default is that all dimensions created at the drawing level are owned by the model they are associated to.

You would have to change a config.pro setting to make them be owned by the drawing:

create_drawing_dims_only yes - gets you drawing owned created dims.

It defaults to NO, which is good. If the dims are ownded by the model, you can gather their tolerances. You cant from
drawing ownded dims. Now this only the understanding that I have come to.

But enither of these satisfies what I need. I actually need to gather all dims ownded by the models associated to views
within the drawing. I obtain them &them compare them to the list gathered formthis code:

pfcDimension2Ds ListShownDimensions (pfcModel Model, /* optional */ pfcModelItemType Type)

But of course I cant find any code on ListShownDimensions, so I will have to figure out the class, subclass, method,
properties connections.

Then after that, I have to hope I can associate the showndimensions that reside in my drawings, get their x.y's. Convert from
model 3D to drawings 2D & place a free symbol at or near the dims. Then find a way for the code to offset the symbol from
the dim, but the api shows no such capability. All this on a schedule...ha..ha

If anybody has code on ListShownDimensions, that would give me a start & I would appreciate it.

L. Jett
[email protected],[email protected]
 
Thanks to Marc Mette on the potcuser.org side, here is the web.link code I used
to obtain what I needed.

I added a little snippet on the symbol side (in & between Marcs code):

var drwmodels = drawing.ListModels();
newWin.document.writeln ("<br>" + "Drawing: " + drawing.FileName + " ( "
+ drwmodels.Count + " drw models )");

var modelitemtype = pfcCreate("pfcModelItemType");

/*--Retrieve the symbol definition from the system--*/

var symDef = drawing.RetrieveSymbolDefinition ("sym_name", void null, void null, true);

for (var i = 0; i < drwmodels.Count; i++) {

drwmodel = drwmodels.Item(i);
var showndims = drawing.ListShownDimensions(drwmodel, modelitemtype.ITEM_DIMENSION);
newWin.document.writeln ("<br>" + "   Model " + (i+1) + ": "
+ drwmodel.FileName + " ( " + showndims.Count + " shown dims )");

for (var j = 0; j < showndims.Count; j++) {

var pnt3d = void null;
var showndim = showndims.Item(j);
var symbol = showndim.Symbol;
var value = showndim.DimValue;
pnt3d = showndim.Location;

newWin.document.writeln ("<br>" + "     Dim " + (j+1) + ": "
+ symbol + " = " + value + " ( " + pnt3d.Item(0)
+ " , " + pnt3d.Item(1) + " , " + pnt3d.Item(2) + " )");

var position = void null;
var instrs = pfcCreate ("pfcDetailSymbolInstInstructions").Create (symDef);
position = pfcCreate ("pfcFreeAttachment").Create (pnt3d);
var allAttachments = pfcCreate ("pfcDetailLeaders").Create ();

position.AttachmentPoint = pnt3d;
allAttachments.ItemAttachment = position;
instrs.InstAttachment = allAttachments;

/*--Set the VariantTexts (for var text)--*/

var vtpp = pfcCreate ("pfcDetailVariantText").Create ("vartext", j+1);
var vtpp2 = pfcCreate ("pfcDetailVariantTexts");
vtpp2.append(vtpp);
instrs.TextValues = vtpp2;

/*--Create and display the symbol--*/

var symInst = drawing.CreateDetailItem (instrs);
symInst.Show();
}
}
 
Hello Jett,


After gone to your e-mal, i understand your idea. I was done similar in Pro-Toolkit.


I do not have much expertise in Java,due to that i can not able to suggest about the further funcaionality to procced.


I can share the video file for you.Are you wokring in a company or you do this project on your own?


With regards,


Kishore V
 

Sponsor

Back
Top