Jump to content

Please help solve VBA problem


Recommended Posts

Posted

i am having a code but there is error coming in its compliation

Can anybody solve my problem!!

 

ActiveDocument.ModelSpace.AddHatch

Sub Test()
   Dim pnt As IntelliCAD.Point
   Dim pnts As IntelliCAD.points
   Dim hatch As IntelliCAD.hatch
   Dim pline As IntelliCAD.LWPolyline
   Dim oLoop(0 To 0) As IntelliCAD.Entity
   ' --- Create a closed LWPolyLine
   Set pnts = Library.CreatePoints()
   Set pnt = ActiveDocument.Utility.GetPoint(, "p1:"): pnts.Add pnt.x, pnt.Y, pnt.z
   Set pnt = ActiveDocument.Utility.GetPoint(pnt, "p2:"): pnts.Add pnt.x, pnt.Y, pnt.z
   Set pnt = ActiveDocument.Utility.GetPoint(pnt, "p3:"): pnts.Add pnt.x, pnt.Y, pnt.z
   Set pnt = ActiveDocument.Utility.GetPoint(pnt, "p4:"): pnts.Add pnt.x, pnt.Y, pnt.z
   Set pline = ActiveDocument.ModelSpace.AddLightWeightPolyline(pnts)
   pline.Closed = True
   pline.Update

   ' --- Set LWPolyLine to outer loop of hatch 
   Set oLoop(0) = pline

   ' --- Create a Hatch
   Set hatch = ActiveDocument.ModelSpace.AddHatch(vicHatchPatternTypePreDefined, "ANSI37")
   hatch.AppendOuterLoop oLoop
   hatch.PatternAngle = 30# ' <---------------- Hatch Angle
   hatch.PatternScale = 3# ' <--------------- Hatch Scale
   hatch.Update
   hatch.Visible = True
   ActiveDocument.Regen vicActiveViewport
End Sub

Posted

The problem seems to be that you are trying to use Intellicad Reference, but with AppendOutherLoop method, wich is part of AutoCad Reference.

Remove that line and use Object.ApplyHatch (SelectionSet)

Where selectionset is the selectionset containing the object to be hatched (sorry),

Posted

If you use IntelliCAD I would recommend switching to Bricscad. There you have the same object model as in AutoCAD, both in VBA, VLisp and C++.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...