PDA

View Full Version : How to append sphere to drawing



PanHasan
8th Mar 2010, 12:28 am
Hi
how can I append a 3d sphere into the drawing. Sample below works for the circle but not for the spheres why and how to solve this ;) thx

Public Sub addSpheres()
Dim lcmd As Editor = Application.DocumentManager.MdiActiveDocument.Edit or
Dim acbaza As Database = lcmd.Document.Database
Using trn As Transaction = acbaza.TransactionManager.StartTransaction
Dim btr As BlockTableRecord = CType(trn.GetObject(acbaza.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim sph As Sphere = New Sphere(1, New Point3d(1.0, 1.0, 1.0), Vector3d.XAxis, Vector3d.YAxis, 0.0, 0.0, 0.0, 0.0)
btr.AppendEntity(sph)
trn.AddNewlyCreatedDBObject(sph, True)
trn.Commit()
End Using
End Sub

ollie
10th Mar 2010, 11:26 pm
You could insert a circle and revolve said circle into a sphere

EDIT:



(setq f(vla-addsphere
(vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object)))
(vlax-3d-point(list 0.0 0.0 0.0 )) ;Insertion point
20.0)) ;Radius
The above code is what you're looking for i think

I don't have VBA in 2010 but the code should be roughly



Activedocument.modelspace.addsphere(insertionPoint , radius)


As far as I am aware pre existing entites don't require a constructor statement in VBA

PanHasan
11th Mar 2010, 02:29 pm
Thx for the solution works fine :)