×
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

Getting relative views of each body of multibody part

Getting relative views of each body of multibody part

Getting relative views of each body of multibody part

(OP)
Hi,
I am trying to automatically create drawing document with number of sheets that match number of bodies in multibody part that is active and opened prior to running the macro. Each sheet would contain relative view of one body. What does happen when running macro as shown below, I do get number of sheets but without any models in it (empty template drawing). My guess is that I am missing the command that drops view onto the sheet, therefore please if anyone can take a look and let me know what I am missing here.
Thanks.


' Only precondition for macro is to have multibody part open
Dim swModel as ModelDoc2
Dim pathName As String = ""
Dim swPart as PartDoc = Nothing
Dim swFeature as Feature = Nothing
Dim swBodyFolder as BodyFolder = Nothing
Dim numberOfBodies As Integer = 0
Dim allBodies As Object ' array
Dim swBody As Body2 = Nothing
Dim swDoc As ModelDoc2 = Nothing
Dim bodyName As String = ""
Dim swDrawing As DrawingDoc = Nothing
Dim firstView As View = Nothing
Dim bolBody As Boolean = False

swModel = swApp.ActiveDoc

pathName = swModel.GetPathName ' path name is string value

swPart = swApp.ActiveDoc

If swPart Is Nothing Then
Exit Sub
End If

swModel = swApp.NewDocument("D:\Macros\Macro_A.drwdot", 0, 0.2159, 0.2794) ' opening new drawing document

swFeature = swPart.FirstFeature
Do While Not swFeature.GetTypeName2 = "SolidBodyFolder"
swFeature = swFeature.GetNextFeature
Loop

If swFeature.GetTypeName2 = "SolidBodyFolder" Then
swBodyFolder = swFeature.GetSpecificFeature2
numberOfBodies = swBodyFolder.GetBodyCount
allBodies = swBodyFolder.GetBodies()
For i = 0 To (numberOfBodies - 1)
swBody = allBodies(i) ' swBody is Body2 and allBodies is array of bodies (object)

bodyName = swBody.Name

swDoc = CType(swApp.ActiveDoc, ModelDoc2)

bolBody = swDoc.Extension.SelectByID2(bodyName, "SOLIDBODY", 0.0254, 0.038, 0.1135, True, 0, Nothing, 0)
bolBody = swDoc.Extension.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)
bolBody = swDoc.Extension.SelectByID2("Right Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

swDrawing = CType(swDoc, DrawingDoc)

firstView = swDrawing.CreateRelativeView(pathName, 0.0972, 0.133, 0, 1)


If i < (numberOfBodies - 1) Then
swDrawing.NewSheet("Sheet" & (i + 2), 0, 0, 0, 0)
End If

Next

End If

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