COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Save as DWG macro

• Email
• Follow

We have been using a macro to save a drawing as a PDF that was last enhanced
by Matthew Lorono.  This works pretty well in that if the save fails, you
get errors returned, such as the file was not writable, maybe because it was

So, I said, since this one is so handy, why not make another one-button push
to save out the DWG copy also.  Great - change the PDFs to DWGs.  Works.
Mostly.  It will save the file properly, but if the file already exists, and
it's read-only, then there still are no errors returned.  It's not that I am
not seeing the returns, the code is telling me that the "MB =
Model.SaveAs4(MyPathConf & "\" & NewName, swSaveAsCurrentVersion,
swSaveAsOptions_Silent, Errs, Warnings)" returns true.

Any thoughts as to why?

WT


 0

See related articles to this posting

On Jan 16, 6:40=A0am, "Wayne Tiffany" <wayne.tiffanyRMVJ...@asi.com>
wrote:
> We have been using a macro to save a drawing as a PDF that was last enhanc=
ed
> by Matthew Lorono. =A0This works pretty well in that if the save fails, yo=
u
> get errors returned, such as the file was not writable, maybe because it w=
as
>
> So, I said, since this one is so handy, why not make another one-button pu=
sh
> to save out the DWG copy also. =A0Great - change the PDFs to DWGs. =A0Work=
s.
> Mostly. =A0It will save the file properly, but if the file already exists,=
and
> it's read-only, then there still are no errors returned. =A0It's not that =
I am
> not seeing the returns, the code is telling me that the "MB =3D
> Model.SaveAs4(MyPathConf & "\" & NewName, swSaveAsCurrentVersion,
> swSaveAsOptions_Silent, Errs, Warnings)" returns true.
>
> Any thoughts as to why?
>
> =A0 WT
WT,

Have the code do a search for the file's existence before executing
the save code.  This will allow you to not rely on errors to take
action, but to allow the code to take the appropriate action before
errors are caused.

Matt Lorono
http://sw.fcsuper.com

 0

That makes some sense, so how do I query it to determine if it's open by

But, still on the original question, why would the PDF save properly return
errors, and the DWG save not return those same errors?

WT


 0

On Jan 16, 5:26=A0pm, "Wayne Tiffany" <wayne.tiffanyRMVJ...@asi.com>
wrote:
> That makes some sense, so how do I query it to determine if it's open by
>
> But, still on the original question, why would the PDF save properly retur=
n
> errors, and the DWG save not return those same errors?
>
> =A0 WT

WT,

It may actually be a bug.  Have you tried the operation manually to
see if you get the same results?  If so, bug.  If not, then maybe it's
something to do with how the code handles the errors.  If it is a bug,
you'll still need a work-around, but it should be reported to S/W

As far as having the code check to see if the file exists, try
checking out MS API help first to see if there is an example already
in there for this kind of action.

Matt Lorono
http://sw.fcsuper.com

 0

Manually works properly.  If the file is read-only it comes back with the
proper notification.  With the API SaveAs4, nothing comes back as a problem.

WT


 0

Wayne,

Running SW2007 sp0.0 here.

I experimented with both SaveAs PDF and SaveAs DWG, and neither one
prompted an error message for me...no matter what the new file was
saved.

I'm guessing the value at the "swSaveAsOptions_Silent" position is
supposed to take care of this. Looking at the SW API Help for SaveAs4,
I found this disclaimer on the bottom of the swSaveAsOptions_e page:
"These options only apply to saving to native SolidWorks file
formats."

If (Dir(MyPathConf & "\" & NewName) = "") Then 'Check if File Doesn't
MB = Model.SaveAs4(strAcadName, swSaveAsCurrentVersion, 0, Errs,
Warnings)
If (MB) Then
'Nothing. Do it this way because looking for "(Not(MB))" is
unreliable.
Else
MsgBox "File was not Created.", vbCritical, "SaveAsDWG"
End If
Else
MsgBox "File Already Exists.", vbCritical, "SaveAsDWG"
End If

Later,
Ken

 0

Also keep in mind that if someone else has the file open you wont be
able to overwrite it, even when the file property wont way its read
only. We have a similar problem with our PDF saving system.

Also our VAR claims that there are some API errors concerning save as
dxf, making it not save each time, sometimes it just skips it for
whatever reason.


 0

We are on 2007 SP5 and I had seen the message about the options only
applying to SW natives, but the PDF save does work properly for me.  If the
file is read-only by the attribute, or if an app has it open, it will return
the proper errors.  The fact that there is a recognized bug about saving to
DXF probably means that same thing applies for DWG.

WT


 0

On Jan 18, 5:13=A0am, "Wayne Tiffany" <wayne.tiffanyRMVJ...@asi.com>
wrote:
> We are on 2007 SP5 and I had seen the message about the options only
> applying to SW natives, but the PDF save does work properly for me. =A0If =
the
> file is read-only by the attribute, or if an app has it open, it will retu=
rn
> the proper errors. =A0The fact that there is a recognized bug about saving=
to
> DXF probably means that same thing applies for DWG.
>
> =A0 WT

WT and Ken,

If you have a working version of your new macro with the addition of
the file name check, I'd be interested in hosting on my site, with new
edit credits going to you and Ken (Tin Man).  Let me know.

Matt Lorono
http://sw.fcsuper.com

 0

8 Replies
868 Views

Similar Articles

12/7/2013 8:53:39 PM
page loaded in 54296 ms. (0)

Similar Artilces:

Exit macro
How do I exit a macro prematurely? Is there a statement like "return;" (c++,java,c#) or "Exit Sub" (VB) equivalent for SAS macro compiler? On Fri, 27 Jul 2007 10:35:27 -0700, abose <hirak99@GMAIL.COM> wrote: >How do I exit a macro prematurely? Is there a statement like >"return;" (c++,java,c#) or "Exit Sub" (VB) equivalent for SAS macro >compiler? Hi, abose, The %return statement, of course :-), let you exit from the currently running macro. Cheers, Chang On 27 Jul, 19:35, abose <hira...@gmail.com> wrote: > How do I exit a macro prematurely? Is there a statement like > "return;" (c++,java,c#) or "Exit Sub" (VB) equivalent for SAS macro > compiler? What I do in my macros is use "%goto error;" and that puts out a message saying what macro is ending when it jumps to the "error:" label. See the end of the following macro. http://www.datasavantconsulting.com/roland/spectre/macros/closerep.sas

Macro Not resovling
I do not understand why this macro is not resolving when n=1. Csn someone tell me. %do n=1 %to 4; %if &n=1 %then %do; %if &&m&i=0009 %then %let excludenew =(where=(type ne 'NEW')); %else %if &&m&i=0010 %then %let excludenew =(where=(type ne 'NEW')); %else %if &&m&i=0011 %then %let excludenew =(where=(type ne 'NEW')); %else %if &&m&i=0012 %then %let excludenew =(where=(type ne 'NEW')); %else %if &&m&i=0101 %then %let excludenew =(where=(type ne 'NEW')); %end; %else %let excludenew= ;

MACRO QUERY
# include<stdio.h> #define NEG(a) -a void main() { int x=1; printf("%d",--1); //statement-1--This is compile time error. printf("%d",-NEG(x)); //statement-2--It works and prints out 1 } In statement-1 expectedly I am getting a compile time error as it is trying to apply a decrement on a constant. but in statement-2, I am not getting compiled error and gets result as 1. I thought macro would expand as --1 and give an error. Why is this anomaly in second statement? On Jan 5, 10:21=A0am, Tagore <c.lang.mys...@gmail.com> wrote: >...; 1. > I thought macro would expand as --1 and give an error. > Why is this anomaly in second statement? -NEG(x) expands to --x, not --1. Tagore <c.lang.myself@gmail.com> writes: > # include<stdio.h> > > #define NEG(a) -a A better way to write this would be: #define NEG(a) (-(a)) But of course you're asking about potential problems caused by the definition without parentheses. > void main() This should be int main(void) And since you're calling printf, you need #include <stdio.h> > { > int x=1; > > printf("

stuck with macro
) # s > > #define XStr(x, y) str(x) ## str(y) > > int > main(void) > { > puts(XStr(A, x)); > return 0; > } > > #gcc -ansi -pedantic -W -Wall new.c && ./a.out > new.c:10:1: error: pasting ")" > and "str" does not give a valid preprocessing token Sorry about that. In case you may also want to stringize a macro value: /* BEGIN new.c */ #include <stdio.h> #define XStr(a, b) #a #b #define x 5 #define str(s) # s #define MStr(a, b) str(a) str(b) int main(void

The TEST_() macro
Newsgroupies: This sample code tests a WTL dialog box. (Fear not, topic police, we see little Windows Template Library code here, and the actual TEST_() macro itself is quite portable.) I like the TEST_() macro better than the usual Test Suite system (where you must write extra code to push each Test Case into its Suite's list), so I wrote a CppUnit clone that uses _only_ the TEST_() macro. Firstly, all TestCases obey the Abstract Template pattern: class TestCase { public: virtual void setUp() {} virtual void runCase() = 0; virtual void..._(suite, target) \ struct suite##target: public suite \ { void runCase(); } \ a##suite##target; \ void suite##target::runCase() TEST_(TestDialog, first_name) { CPPUNIT_ASSERT_EQUAL( "Ignatz", m_aDlg.getText(IDC_EDIT_FIRST_NAME) ); } TEST_(TestDialog, last_name) { CPPUNIT_ASSERT_EQUAL( "Mouse", m_aDlg.getText(IDC_EDIT_LAST_NAME) ); } The object instances went inside the TEST_() macro, which uses token##pasting to give them unique

Macro parameters
Multiple macro parameters can be nested inside brackets, for example \def\breftwo[#1,#2]{[\expandargcond{#1},\expandargcond{#2}]} together with \def\expandargcond#1{% {\expandafter}\expandafter\ifx\csname #1\endcsname\@undefined{\rm?}% \else\csname #1\endcsname\fi} (catcode changes for @ omitted) works fine for a 2-citation: \def\aaa{31} \def\bbb{45} \breftwo[aaa,bbb] expands to [31,45] while \breftwo[aaa,BBB] expands to [31,?] Question: can a user-defined TeX macro be written to receive a variable number of arguments in a list? I was thinking of a \bref macro that can be called with 1 to 9 arguments, counts the arguments supplied inside [ ] and emits appropriate tokens. If zero arguments, emit []. Examples: \bref[aaa,bbb,ccc,bbb,aaa] -> [31,45,?,45,31] \bref[ccc] -> [?] \bref[] -> [] On Thu, 16 Nov 2006, carlos@colorado.edu wrote: > Multiple macro parameters can be nested inside brackets, for example > > \def\breftwo[#1,#2]{[\expandargcond{#1},\expandargcond{#2}]} > > together with > > \def\expandargcond#1{% > {\expandafter}\expandafter\ifx\csname #1\endcsname

to iterate a macro
Hi, I have a macro %iterate. with no return value. How do I execute this macro 100 times? I tried something like: data one; do i=1 to 100; %iterate; end; run; but its giving an error saying that a do loop is open. Thanks, Mayukh Mayukh, =20 It depends one what your macro definition actual has in it to how you = can call it. =20 if your macro has open SAS code and is constructed correctly then your = method would work. However, it coyld be the case that it needs to be = called thusly,=20 =20 %macro loop; %do i =3D 1 to 100; %iteterate; %end; %mend; =20 In short show us teh macro definition for %iterate and tell us what you = are trying to do with it. Perhaps your on ethe righ track or perhaps we = could show you another way that is easier or more readable and = maintainable. =20 =20 Toby=20 ________________________________ From: SAS(r) Discussion on behalf of Mayukh Dass Sent: Thu 12/16/2004 10:06 PM To: SAS-L@LISTSERV.UGA.EDU Subject: to iterate a macro Hi, I have a macro %iterate. with no return value. How do I execute this macro 100 times? I tried something like: data one; do i=3D1 to 100; %iterate; end; run; but its giving an error saying

CALMAR2 Macro
Does anyone have a copy of the documentation (in English) for the Calmar2 macro? I am interested in understanding the mathematical underpinnings of the theory behind this calibration method. Thanks. Seema. Seema, Take a look at: http://xrl.us/rihf It's not an English version user's guide, but may be able to answer your questions. HTH, Art ----------- On Thu, 31 Aug 2006 09:31:54 -0700, svs <seema.var@GMAIL.COM> wrote: >Does anyone have a copy of the documentation (in English) for the >Calmar2 macro? I am interested in understanding the mathematical >underpinnings of the theory behind this calibration method. >Thanks. >Seema. art297@NETSCAPE.NET replied: >On Thu, 31 Aug 2006 09:31:54 -0700, svs <seema.var@GMAIL.COM> wrote: > > >Does anyone have a copy of the documentation (in English) for the > >Calmar2 macro? I am interested in understanding the mathematical > >underpinnings of the theory behind this calibration method. > >Thanks. > >Seema. >Seema, > >Take a look at: http://xrl.us/rihf >It's not an English version user's guide, but may be able to answer your >questions. >

\unique macro?
I've searched for this on google, but to no avail: Is there a package that provides a \unique macro, where by a \unique macro I mean something that returns a unique list of its arguments? E.g. \unique{hello, goodbye, hello} would expand to hello, goodbye It would expand its arguments before doing the uniqueness comparison. E.g. \def\watcha{hello} \def\tata{goodbye} \def\seeya{goodbye} would expand to hello, goodbye Any pointers gratefully received, David. David C Sterratt <david.c.sterratt@ed.ac.uk> wrote: > I've searched for this on google, but to no avail: > > Is there a package that provides a \unique macro, where by a \unique > macro I mean something that returns a unique list of its arguments? > E.g. > > \unique{hello, goodbye, hello} > > would expand to > > hello, goodbye > > It would expand its arguments before doing the uniqueness > comparison. E.g. > > \def\watcha{hello} > \def\tata{goodbye} > \def\seeya{goodbye} > > would expand to > > hello, goodbye \documentclass{article} \usepackage{keyval} \makeatletter \newcommand*{\unique}[1]{% \global\let\unique@list\@empty

Macro woes
*sigh* I wasn't expecting to create another thread so quickly :) Can someone explain to me what the difference here is, and why I get the results that I do: (defmacro test (x) (functionp ,x)) (test #'+) => T --------------------- (defmacro test (x) ,(functionp x)) (test #'+) => NIL My mind tells me that there should be no difference between the two of these situations, but evidently there is. In case it matters, I'm using Corman Lisp 2.5. Desparately seeking enlightenment :) Jeff "Jeff" <jma@insightbb.com> writes: > My mind tells me that there should be no difference between the two of > these situations, but evidently there is. In case it matters, I'm using > Corman Lisp 2.5. marcoexpand is your friend. CL-USER> (defmacro test (x) (functionp ,x)) TEST CL-USER> (macroexpand '(test #'+)) (FUNCTIONP #'+) T CL-USER> (defmacro test (x) ,(functionp x)) TEST CL-USER> (macroexpand '(test #'+)) NIL T the second macro is calling functionp on the form (function +) and expanding into that. a list is not a function. so your second macro always expands into NIL. evaling NIL returns NIL