.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Programmatically creating blocks with Dynamic Parameters

1 REPLY 1
Reply
Message 1 of 2
Anonymous
824 Views, 1 Reply

Programmatically creating blocks with Dynamic Parameters

I have been unable to find an example that leads me in the correct direction.
I was wondering if you could show me how to
Create a simple block with a line and a circle
Create three visibility states
1 with line visible only
1 with circle visible only
1 with both circle and line visible

It would also be nice if you could include an example of how to place a block on a drawing selecting one of the 3 visibility states

This is a "snippet" of working code that creates a simple block with attributes. I have not included all of the code, but you get the idea. This block that this code creates includes a lpolyline. I would like to add the capability to integrate visiblity states relative to this lpolyline.

I guess that my big question is. Is this possible using the .net API?

----------------------------------------------
oAcadTR = oAcadTM.StartTransaction
Dim oFlagBoxp1 As New Autodesk.autocad.geometry.Point2d(BoxSize / 2.0, BoxSize / 2.0)
Dim oFlagBoxp2 As New Autodesk.autocad.geometry.Point2d(BoxSize / 2.0, -BoxSize / 2.0)
Dim oFlagBoxp3 As New Autodesk.autocad.geometry.Point2d(-BoxSize / 2.0, -BoxSize / 2.0)
Dim oFlagBoxp4 As New Autodesk.autocad.geometry.Point2d(-BoxSize / 2.0, BoxSize / 2.0)
Dim oNoteIDPoint2d As New Autodesk.AutoCAD.Geometry.Point2d(0, 0.5)
Dim oNoteShortDescPoint2d As New Autodesk.AutoCAD.Geometry.Point2d(0, 1)
Dim oNoteCommentPoint2d As New Autodesk.AutoCAD.Geometry.Point2d(0, -0.5)
Dim oNoteIDPoint3d As New Autodesk.AutoCAD.Geometry.Point3d(0, 0.5, 0)
Dim oNoteShortDescPoint3d As New Autodesk.AutoCAD.Geometry.Point3d(0, 1, 0)
Dim oNoteCommentPoint3d As New Autodesk.AutoCAD.Geometry.Point3d(0, -0.5, 0)


Dim oNoteNoAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(Autodesk.AutoCAD.Geometry.Point3d.Origin, "1", "NoteNumber", "Note Number", StyleID)
With oNoteNoAttDef
.Invisible = False
.HorizontalMode = TextHorizontalMode.TextMid
.VerticalMode = TextVerticalMode.TextVerticalMid
End With
Dim oShortDescAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(oNoteShortDescPoint3d, "", "ShortDesc", "Short Description", StyleID)
With oShortDescAttDef
.Invisible = True
.HorizontalMode = TextHorizontalMode.TextLeft
.VerticalMode = TextVerticalMode.TextVerticalMid
.Position = oNoteShortDescPoint3d
.AlignmentPoint = oNoteShortDescPoint3d
End With
Dim oNoteIDAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(oNoteIDPoint3d, "", "ID", "DatabaseID", StyleID)
With oNoteIDAttDef
.Invisible = True
.HorizontalMode = TextHorizontalMode.TextLeft
.VerticalMode = TextVerticalMode.TextVerticalMid
.Position = oNoteIDPoint3d
.AlignmentPoint = oNoteIDPoint3d
End With
Dim oCommentAttDef As New Autodesk.AutoCAD.DatabaseServices.AttributeDefinition(oNoteCommentPoint3d, "", "Comments", "Comments", StyleID)
With oCommentAttDef
.Invisible = True
.HorizontalMode = TextHorizontalMode.TextLeft
.VerticalMode = TextVerticalMode.TextVerticalMid
.Position = oNoteCommentPoint3d
.AlignmentPoint = oNoteCommentPoint3d
End With
Dim oFlagBox As New Autodesk.AutoCAD.DatabaseServices.Polyline(4)
With oFlagBox
.AddVertexAt(0, oFlagBoxp1, 0, -1, -1)
.AddVertexAt(1, oFlagBoxp2, 0, -1, -1)
.AddVertexAt(2, oFlagBoxp3, 0, -1, -1)
.AddVertexAt(3, oFlagBoxp4, 0, -1, -1)
.Closed = True
.Layer = LayerName
End With
Dim oNotesBlockTableRecord As BlockTableRecord = New BlockTableRecord
oNotesBlockTableRecord.Name = BlockName
oBlockTable = CType(oAcadTR.GetObject(oAcadDB.BlockTableId, OpenMode.ForWrite, False), BlockTable)
Dim oNotesBlockTableRecordID = oBlockTable.Add(oNotesBlockTableRecord)
oAcadTM.AddNewlyCreatedDBObject(oNotesBlockTableRecord, True)
oNotesBlockTableRecord.AppendEntity(oFlagBox)
oNotesBlockTableRecord.AppendEntity(oNoteNoAttDef)
oNotesBlockTableRecord.AppendEntity(oShortDescAttDef)
oNotesBlockTableRecord.AppendEntity(oNoteIDAttDef)
oNotesBlockTableRecord.AppendEntity(oCommentAttDef)
oAcadTR.AddNewlyCreatedDBObject(oFlagBox, True)
oAcadTR.AddNewlyCreatedDBObject(oNoteNoAttDef, True)
oAcadTR.AddNewlyCreatedDBObject(oShortDescAttDef, True)
oAcadTR.AddNewlyCreatedDBObject(oNoteIDAttDef, True)
oAcadTR.AddNewlyCreatedDBObject(oCommentAttDef, True)
oAcadTR.Commit()
oAcadTR.Dispose()
---------------------------------------
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

From the contents of this posting (From the ObjectArx Group), I gather that the methods to add dynamic properties to blocks have not been exposed in this release.

Quote ------------------------


1) There is no exposed API for the creation of dynamic blocks. I have
at least two clients who have large libraries of blocks that represent
their product line. These companies could benefit greatly from using
dynamic blocks. However, it is not cost effective for them to manually
add the proper parameters to over 15,000 blocks. The logic for the
addition of the 'parametrics' could be programmed but there is no API to
do so. I suppose one could script the process (although I'll bet I'd
run into some major dead ends for some things that only have dialog
interfaces). The associated classes are exported by acdb16.dll, but
since there are no headers or libs for the classes I am unable to use
them. Major oversight IMO 😞

2) Why is there a limit (of 1) to the number of visibility parameters?
I need to be able to map multiple visibility parameters to different
product options. This one means I can't recommend dynamic blocks to my
clients who need this functionality 😞

Anybody else disappointed with dynamic blocks from the API perspective?

In case you haven't snooped acdb16.dll for 2006, here's a short list of
what we're missing:

AcDbBlock1PtParameter
AcDbBlock1PtParameterEntity
AcDbBlo ck2PtParameter
AcDbBlock2PtParameterEntity
AcDbBlockAction
AcDbBlockAct ionEntity
AcDbBlockActionEntityWithBasePt
AcDbBlockActionWithBasePt
AcD bBlockAlignmentGrip
AcDbBlockAlignmentGripEntity
AcDbBlockAlignmentParamet er
AcDbBlockAlignmentParameterEntity
AcDbBlockArrayAction
AcDbBlockArra yActionEntity
AcDbBlockBasepointParameter
AcDbBlockBasepointParameterEntit y
AcDbBlockElement
AcDbBlockElementEntity
AcDbBlockElementEntityMgr
AcDbBlockFlipAction
AcDbBlockFlipActionEntity
AcDbBlockFlipGrip
AcDbBlo ckFlipGripEntity
AcDbBlockFlipParameter
AcDbBlockFlipParameterEntity
Ac DbBlockGrip
AcDbBlockGripEntity
AcDbBlockLinearGrip
AcDbBlockLinearGrip Entity
AcDbBlockLinearParameter
AcDbBlockLinearParameterEntity
AcDbBloc kLookupAction
AcDbBlockLookupActionEntity
AcDbBlockLookupGrip
AcDbBlock LookupGripEntity
AcDbBlockLookupParameter
AcDbBlockLookupParameterEntityAcDbBlockMoveAction
AcDbBlockMoveActionEntity
AcDbBlockParamValueSet
AcDbBlockParameter
AcDbBlockParameterEntity
AcDbBlockPointParameter
AcD bBlockPointParameterEntity
AcDbBlockPolarGrip
AcDbBlockPolarGripEntity
AcDbBlockPolarParameter
AcDbBlockPolarParameterEntity
AcDbBlockPolarStretc hAction
AcDbBlockPolarStretchActionEntity
AcDbBlockRotateAction
AcDbBlo ckRotateActionEntity
AcDbBlockRotationGrip
AcDbBlockRotationGripEntity
AcDbBlockRotationParameter
AcDbBlockRotationParameterEntity
AcDbBlockScale Action
AcDbBlockScaleActionEntity
AcDbBlockStretchAction
AcDbBlockStret chActionEntity
AcDbBlockVisibilityGrip
AcDbBlockVisibilityGripEntity
Ac DbBlockVisibilityParameter
AcDbBlockVisibilityParameterEntity
AcDbBlockXYG rip
AcDbBlockXYGripEntity
AcDbBlockXYParameter
AcDbBlockXYParameterEnti ty

--
Best regards,

Byron Blattel
CADwerx--Applications for AutoCAD
Autodesk Registered Developer
Contact Info @ http://www.cadwerx.net
Custom Programming Services - ObjectARX/C++/MFC/ASP/STL/ATL/ISAPI...

--------------End Quote

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost