×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

API call

API call

API call

(OP)
Does anyone know the call for the command "make drawing from
part/assembly"  This is a SW04 command.

I'm trying to write a macro that uses that function to create a drawing using a specific border.

Thanks in advance.

RE: API call

swApp.LoadFile2 "Type the pathname and template filename.drwdot here""
Set Part = swApp.ActiveDoc
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
swApp.ActiveDoc.ActiveView.FrameState = 1
Set Part = swApp.NewDocument("type the pathname and template filename.drwdot here", 2, 0.2794, 0.4318)

Regards,
Jon
jgbena@yahoo.com

RE: API call

oops forgot to type the rest...

Create a template that uses that specific sheet format.  Use that drwdot file in the pathname argument.

You could however, create a form that is called when the macro is run that will ask you to browse for the template if you intend to be able to select from different templates, and use that value in the pathname argument instead.. depends on what you want to do.

Regards,
Jon
jgbena@yahoo.com

RE: API call

(OP)
Jon, here is the code I was using.

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc
swApp.LoadFile2 "R:\Cad\Solidworks\SolidWorks 04 Templates\Drawing Templates\Metric Drawing.drwdot", ""
Set Part = swApp.ActiveDoc
Set Part = swApp.NewDocument("R:\Cad\Solidworks\SolidWorks 04 Templates\Drawing Templates\IN9001(M B assy).slddrt", 0, 0, 0)

When I put yours in place my sheet format was not visible.  It was there because if I did a edit sheet format it showed up.
It still doesn't seem like the drawing is linked back to the part.

RE: API call

Hmmm

Curious... I can see the border, thats no problem.. but the issue I have that you just drew my attention to is that I had to insert the model manually... I tied using a template with predefined views and they came in empty...

But the sheet format comes in fine..

What service pack are you using?

Regards,
Jon
jgbena@yahoo.com

RE: API call

(OP)
On my machine I have SP1.0.  I will test it on the machine next to me that has 2.1 on it.
Do you get the ghost image border, it's like a 1/2" border around the left and top of the modeling area.  It shows what was next up on the desktop.

RE: API call

i am on sp0.0 (sp1 - 2.1 have been a little too buggy for my.  Im waiting for 3.0 to come out!

Regards,
Jon
jgbena@yahoo.com

RE: API call

(OP)
I can't get the same outcome everytime on my machine or the one with SP2.1 on it.
Still working on it though.
In your statement Set Part = swApp.NewDocument("type the pathname and template filename.drwdot here", 2, 0.2794, 0.4318)
Where did you get the values , 2, 0.2794. . . .
I can't find anywhere that defines those numbers.

RE: API call

Yogi,

The Convention is like this.

NewDocument ( templateName, paperSize, width, height )

Papersize is a hardcoded preset list of sizes associated with a number.. for instance see the list below:

1= 11 x 8.5
2= 11 x 17
3= 22 x 17
4= 22 x 34
5= 34 x 44
6= 8.5 x 11
7= 11 x 8.5
8= 11.75 x 16.5
9= 16.5 x 23.375
10= 23.5 x 33

The width and Height values are generally unused or ignored unless you want to use a custom paper size in which case I think that you would use 12 as the papersize value and these numbers are the width and height of the paper that you wish to create.. be aware.. these values are in meters.

Regards,
Jon
jgbena@yahoo.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources