Hi
Need help with API that changes the layer of a selected entity in a drawing document. Any ideas?
Thanks
Hi
Need help with API that changes the layer of a selected entity in a drawing document. Any ideas?
Thanks
Have you tried recording a macro?
TOP
Yes, but it doesn't record the actions when I change layer.
Layer is set as a property of an object in a drawing. Get the selected object using the Selection Manager, then change the object's property. You probably can get away with using a generic "Object" variable for the entities whose layer you wish to change, as long as that entity has a Layer property associated with it.
If you do not know how to use the Selection Manager, it's time to learn. Macro recording won't help much there.
Thanks, now I got it to work!
Hmm, it doesn't seem to work the same way when the selected entity is a dimension. Any ideas about this?
Dimensions can be tricky. When you select a dimension, the selected object type is usually a "DisplayDimension". From this object, you need to access the "Annotation" object using "DisplayDimension::GetAnnotation".
Example code below takes a generic object and sets "Anno" to the Annotation object if it is a DisplayDimension. After that, you can set SelectedObject = Anno or just use Anno.Layer to change layer.
Dim SelectedObject as Object Dim DispDim as SldWorks.DisplayDimension Dim Anno as SldWorks.Annotation Set DispDim=SelectedObject If Not DispDim is Nothing Then Set Anno = SelectedObject.GetAnnotation
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.