SimplifiedLogic / creoson

OpenSource Automation using JSON Transactions for PTC's CREO Parametric
http://www.creoson.com
MIT License
83 stars 23 forks source link

Drawing : GetFormatPageList #12

Closed DieSwartKat closed 5 years ago

DieSwartKat commented 5 years ago

Would it be possible to build a function in CREOSON that returns the format used in a drawing per page? I need to identify what drawings are used for, so that I can name them accordingly. I cannot use the active part/assembly as we often have more than one drawing for the same part/assembly but with different formats. The only way to distinguish between these drawings would be to identify which format is used.

I'm open to suggestion should you feel there is an alternative way to solve this problem.

Kind regards

davidhbigelow commented 5 years ago

What about the drawing : get_sheet_size as a possible workaround?

On Fri, Jul 5, 2019 at 1:17 PM DieSwartKat notifications@github.com wrote:

Would it be possible to build a function in CREOSON that returns the format used in a drawing per page? I need to identify what drawings are used for, so that I can name them accordingly. I cannot use the active part/assembly as we often have more than one drawing for the same part/assembly but with different formats. The only way to distinguish between these drawings would be to identify which format is used.

I'm open to suggestion should you feel there is an alternative way to solve this problem.

Kind regards

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SimplifiedLogic/creoson/issues/12?email_source=notifications&email_token=AAMSRJOP4PJCR3MELYY32KLP556YXA5CNFSM4H6M3XCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G5TCIJA, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMSRJISGWNZ3OZDOUWT633P556YXANCNFSM4H6M3XCA .

-- David Bigelow, President Simplified Logic, Inc https://www.simplifiedlogic.com | SimilarParts.ai C: 317-431-5454

DieSwartKat commented 5 years ago

What about the drawing : get_sheet_size as a possible workaround? On Fri, Jul 5, 2019 at 1:17 PM DieSwartKat @.***> wrote: Would it be possible to build a function in CREOSON that returns the format used in a drawing per page? I need to identify what drawings are used for, so that I can name them accordingly. I cannot use the active part/assembly as we often have more than one drawing for the same part/assembly but with different formats. The only way to distinguish between these drawings would be to identify which format is used. I'm open to suggestion should you feel there is an alternative way to solve this problem. Kind regards — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#12?email_source=notifications&email_token=AAMSRJOP4PJCR3MELYY32KLP556YXA5CNFSM4H6M3XCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G5TCIJA>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMSRJISGWNZ3OZDOUWT633P556YXANCNFSM4H6M3XCA . -- David Bigelow, President Simplified Logic, Inc https://www.simplifiedlogic.com | SimilarParts.ai C: 317-431-5454

Thanks good suggestion, but the get_sheet_size command only return the size (A4, A3, etc) of the layout and not the name of the format used (*.frm). That will not be enough of a distinguisher to help identify what the drawing is used for.

davidhbigelow commented 5 years ago

Hmmm.. it looks like it is possible in JLINK... but like anything else - we would have to verify that it works before we implement a change.

But as a possible (short term) workaround... I would look for a model parameter that is typically associated with the type of drawing you are looking to identify (e.g. plastic part vs sheet metal vs weldment etc etc...) and use that if you can in your logic. This assumes corporate standards are established and the part/assembly is more descriptive than the drawing format used as to "what it is"

On Fri, Jul 5, 2019 at 1:33 PM DieSwartKat notifications@github.com wrote:

What about the drawing : get_sheet_size as a possible workaround? … <#m-7012370326668556467> On Fri, Jul 5, 2019 at 1:17 PM DieSwartKat @.***> wrote: Would it be possible to build a function in CREOSON that returns the format used in a drawing per page? I need to identify what drawings are used for, so that I can name them accordingly. I cannot use the active part/assembly as we often have more than one drawing for the same part/assembly but with different formats. The only way to distinguish between these drawings would be to identify which format is used. I'm open to suggestion should you feel there is an alternative way to solve this problem. Kind regards — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#12 https://github.com/SimplifiedLogic/creoson/issues/12?email_source=notifications&email_token=AAMSRJOP4PJCR3MELYY32KLP556YXA5CNFSM4H6M3XCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G5TCIJA>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMSRJISGWNZ3OZDOUWT633P556YXANCNFSM4H6M3XCA . -- David Bigelow, President Simplified Logic, Inc https://www.simplifiedlogic.com | SimilarParts.ai C: 317-431-5454

Thanks good suggestion, but the get_sheet_size command only return the size (A4, A3, etc) of the layout and not the name of the format used (*.frm). That will not be enough of a distinguisher to help identify what the drawing is used for.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/SimplifiedLogic/creoson/issues/12?email_source=notifications&email_token=AAMSRJMAJ6ARX3CE7DNJVSTP56AWDA5CNFSM4H6M3XCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKALEA#issuecomment-508822928, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMSRJJY6GP3XGKTQJHME3TP56AWDANCNFSM4H6M3XCA .

-- David Bigelow, President Simplified Logic, Inc https://www.simplifiedlogic.com | SimilarParts.ai C: 317-431-5454

phaleth commented 5 years ago

The following might help, it uses fmt setter.

Window window = session.GetCurrentWindow();
Model model = window.GetModel();
if (model.GetType() != ModelType.MDL_DRAWING) {
    throw new RuntimeException("Current model is not a drawing.");
}

Model2D drwModel = (Model2D) model;
String formatFileNameInclExt = formatFileName + ".frm";
int currentSheetNum = drwModel.GetCurrentSheetNumber();

ModelDescriptor modelDescr = pfcModel.ModelDescriptor_CreateFromFileName(formatFileNameInclExt);
RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create();
rmo.SetAskUserAboutReps(false);

DrawingFormat format = null;
try {
    format = (DrawingFormat) session.RetrieveModelWithOpts(modelDescr, rmo);
} catch (jxthrowable x) {
    throw new RuntimeException("Failed to retrive the format into session: " + x);
}

drwModel.SetSheetFormat(currentSheetNum, format, null, null);
drwModel.UpdateTables();
davidhbigelow commented 5 years ago

Wow! Thanks!!!!

Feel free to contribute more functions and ideas!!!

On Sat, Jul 6, 2019 at 5:24 AM phaleth notifications@github.com wrote:

The following might help, it uses fmt setter.

Window window = session.GetCurrentWindow(); Model model = window.GetModel(); if (model.GetType() != ModelType.MDL_DRAWING) { throw new RuntimeException("Current model is not a drawing."); }

Model2D drwModel = (Model2D) model; String formatFileNameInclExt = formatFileName + ".frm"; int currentSheetNum = drwModel.GetCurrentSheetNumber();

ModelDescriptor modelDescr = pfcModel.ModelDescriptor_CreateFromFileName(formatFileNameInclExt); RetrieveModelOptions rmo = pfcSession.RetrieveModelOptions_Create(); rmo.SetAskUserAboutReps(false);

DrawingFormat format = null; try { format = (DrawingFormat) session.RetrieveModelWithOpts(modelDescr, rmo); } catch (jxthrowable x) { throw new RuntimeException("Failed to retrive the format into session: " + x); }

drwModel.SetSheetFormat(currentSheetNum, format, null, null); drwModel.UpdateTables();

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/SimplifiedLogic/creoson/issues/12?email_source=notifications&email_token=AAMSRJIGFOVH3RJYBS2ILLLP6BQEJA5CNFSM4H6M3XCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKV5FA#issuecomment-508911252, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMSRJIBSTI4QLHX2JWC2ZTP6BQEJANCNFSM4H6M3XCA .

-- David Bigelow, President Simplified Logic, Inc https://www.simplifiedlogic.com | SimilarParts.ai C: 317-431-5454

adama2000 commented 5 years ago

I've added two new functions to get and set the sheet format -- the get function will return the format file name and full name. They'll be included in the next release.

DieSwartKat commented 5 years ago

You Guys ROCK! Thanks for including get_sheet_format in the new CREOSON 2.5 release. We are implementing this as of today.

I love the fact that it returns both the FORMAT and the TEMPLATE used, this gives us extra functionality to make sure we keep the formats of drawings up to date.

Is there any place, or method where we can show what is possible with CREOSON. I'm considering opening a YouTube channel, but would like to reference Simplified Logics for the great work you are doing on CREOSON?

davidhbigelow commented 5 years ago

HA - thanks it is a team effort + community + customer feedback that makes this better.

I love the idea of a YouTube Channel for contributions like this... We have a CREOSON YouTube Playlist under our Simplified Logic (NitroMation) YouTube Channel that we have been adding things as we find them:

https://www.youtube.com/playlist?list=PLcWd1Ea7i_twWMA6NjkrfLsYpeNVQ9anw

Youtube has a weird policy on creating specific named sites - I would be open to that if it i makes sense.

It is a good idea... If you want to publish on your site and let us know you have done it, we can add it to our playlists so that people have a better chance of finding example and use cases.

What do you think?