Change layer of object. But what kind of object?

Change layer of object. But what kind of object?

Anonymous
Not applicable
435 Views
3 Replies
Message 1 of 4

Change layer of object. But what kind of object?

Anonymous
Not applicable

 

Hello,
I have a script to assign a modell sketch to the drawing. The modell sketch has a circle and a text.
I now want to change the layer of the text by vba. But what kind of object is it? And how to change its layer? I simple want to change its layer from "Symbol (ISO)" to "MyLayer" in example.

 

Unbenannt.png

0 Likes
436 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

A little pump with informations. I use following code to asset a special layer to the drawlines of a modellsketch wich is integrated into the drawing by the planasketchproxy.


          ' Get the TransientsObjects object to use later.
         Dim transObjsZEI As TransientObjects
         Set transObjsZEI = ThisApplication.TransientObjects
         
         Set oViewA = oDrawingDoc.ActiveSheet.DrawingViews(1)
         Dim drawcurvesZEI As DrawingCurvesEnumerator
         Set drawcurvesZEI = oViewA.DrawingCurves(oSketchProxyZEI)
         If Err.Number = 0 Then
            On Error GoTo 0
            ' Create an empty collection.
            Dim objCollZEI As ObjectCollection
            Set objCollZEI = transObjsZEI.CreateObjectCollection()

            ' Add the curve segments to the collection.
            Dim drawCurveZEI As DrawingCurve
            For Each drawCurveZEI In drawcurvesZEI
               Dim segmentZEI As DrawingCurveSegment
               For Each segmentZEI In drawCurveZEI.Segments
                  objCollZEI.Add segmentZEI
               Next
            Next

            ' Change the layer of all of the segments.
            Call oViewA.Parent.ChangeLayer(objCollZEI, oNewLayerZEI)
         End If


As you can see, the code collects the lines as drawingcurves in a collection (objCollZEI) and sets them to layer oNewLayerZEI.
If I am right, I need to add the text to the objCollZei, too and thats all?!

Anyone?! I am right? Wrong?

Added an example of the first post.

 

0 Likes
Message 3 of 4

HermJan.Otterman
Advisor
Advisor

I don't see it aswell.

 

If you select the text, than start the VBA editor, create a watch and look at the "selectset" you can find the parrent.

 

but if you go there starting with the application, this object can't be found...??

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 4 of 4

Anonymous
Not applicable

First thx for your replay.
I dont knew what you meen with "watch". How can I make a watch?

The VBA code opens all planarsketches and look them up for a sketch called "draw".
If a sketch is found, it sets all curves to visible in the drawing sheet.
But not text boxes and everything else. But I need all invormation to be visible.

One solution is to set the "text" visible too.
Or simple set all informations visible.

        ' change color to red

        Dim oColorZEI As Color
        Set oColorZEI = oNewLayerZEI.Color

        oColorZEI.Red = "0"
        oColorZEI.Green = "191"
        oColorZEI.Blue = "255"
        oNewLayerZEI.Color = oColorZEI
        oNewLayerZEI.LineType = LineTypeEnum.kContinuousLineType
        
          ' Get the TransientsObjects object to use later.
         Dim transObjsZEI As TransientObjects
         Set transObjsZEI = ThisApplication.TransientObjects
         
         Set oViewA = oDrawingDoc.ActiveSheet.DrawingViews(1)
         Dim drawcurvesZEI As DrawingCurvesEnumerator
         Set drawcurvesZEI = oViewA.DrawingCurves(oSketchProxyZEI)
         If Err.Number = 0 Then
            On Error GoTo 0
            ' Create an empty collection.
            Dim objCollZEI As ObjectCollection
            Set objCollZEI = transObjsZEI.CreateObjectCollection()

            ' Add the curve segments to the collection.
            Dim drawCurveZEI As DrawingCurve
            For Each drawCurveZEI In drawcurvesZEI
               Dim segmentZEI As DrawingCurveSegment
               For Each segmentZEI In drawCurveZEI.Segments
                  objCollZEI.Add segmentZEI
               Next
            Next

            ' Change the layer of all of the segments.
            Call oViewA.Parent.ChangeLayer(objCollZEI, oNewLayerZEI)
         End If

In VBA Code the code

 

            ' Add the curve segments to the collection.
            Dim drawCurveZEI As DrawingCurve
            For Each drawCurveZEI In drawcurvesZEI
               Dim segmentZEI As DrawingCurveSegment
               For Each segmentZEI In drawCurveZEI.Segments
                  objCollZEI.Add segmentZEI
               Next
            Next

 Has to be changed to add all invormation or add text as well. But I dont knew how I can add the text or all.

0 Likes