I have created a NET routine which, when executed, creates a schematic drawing representation of the parent (active drawing). All of the procedures execute as they should, however one is a mystery. HATCH
On the schematic (inactive document) the hatch appears with the Autocad default settings for the pattern used.
The properties that I am looking at are: The pattern scale and the hatch angle.
The new hatch pattern is displayed with a pattern scale of 1.0 and a hatch angle of 0.0 when they should be
displayed with a pattern scale of 0.5 and a hatch angle of 45
Upon reviewing the hatch properties, by double clicking on the offending hatch pattern, I find that the values are
are correct and as expected (0.5 and 45). By closing the hatch property dialog, the hatch pattern updates itself.
Why doesn't this occur automatically, even linetypes do not appear correctly until a regen is manually involked?
Is it because the hatch pattern or other elements are not being drawn on the active document?
Is this just Autocad?
I have attempted to do the same test via COM and the results are the same.
I can't believe that no one programically creates supporting documents from a parent drawing.
Below is some code:
'
' Create the hatch object and append it to the block table record
Dim acHatch As Hatch = New Hatch()
'
' Set the properties of the hatch object
acHatch.SetHatchPattern(HatchPatternType.PreDefined, "ANSI31")
acHatch.PatternScale = 0.5
acHatch.PatternAngle = Math.PI * 0.25
'
' Add the hatch object to the new database. If these 3 lines of code are before the pattern settings
' an "eAmbiguousObject" error will occur when the hatch object is evaluated.
acHatch.SetDatabaseDefaults(acNewDb)
acBlkTblRec.AppendEntity(acHatch)
acTrans.AddNewlyCreatedDBObject(acHatch, True)
'
' Define the host working database. If this is not added here the hatch does not appear until the
' document is saved and reopened
HostApplicationServices.WorkingDatabase = acHatch.Database
acHatch.Associative = True
acHatch.AppendLoop(HatchLoopTypes.[Default], acObjIdColl)
acHatch.EvaluateHatch(True)
'
' Save the new object to the database
acTrans.Commit()