Apply hidden line in a component by API

Apply hidden line in a component by API

fagmj
Explorer Explorer
602 Views
2 Replies
Message 1 of 3

Apply hidden line in a component by API

fagmj
Explorer
Explorer

hidden_lines.jpg

 

How to apply the "Hidden Lines" option to a component in a drawing view, using the API? I didn't find anything in Programming Help about this.

0 Likes
603 Views
2 Replies
Replies (2)
Message 2 of 3

fagmj
Explorer
Explorer

I was able to achieve this running the command directly:

 

    Dim oControlDef As ControlDefinition
    Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingBodyHiddenLinesCtxCmd")
    oControlDef.Execute

Now I wonder how I could change the layer of the already selected lines.

0 Likes
Message 3 of 3

herrwolf1
Enthusiast
Enthusiast

Hi fagmj,

I'm trying to solve this too. How did you select the component to run the command on? The following code doesn't work. 

 

        public void SetCompOccHiddenLines(int _viewIndex, string _occName, bool _include)
        {
            // Set a reference to the view's referenced model.
            Document _doc = View(_viewIndex).ReferencedDocumentDescriptor.ReferencedDocument;

            // Validate the document type.
            if (!ValidateDocType(DocumentTypeEnum.kAssemblyDocumentObject, _doc)) return;

            // Set a reference to the component definition.
            AssemblyDocument _asmDoc = (AssemblyDocument)_doc;
            AssemblyComponentDefinition _asmCompDef = _asmDoc.ComponentDefinition;

            // Get all leaf occurrences from the assembly model.
            ComponentOccurrencesEnumerator _occEnum = _asmCompDef.Occurrences.AllLeafOccurrences;

            foreach (ComponentOccurrence _occ in _occEnum)
            {
                // Validate this occurrence matches the supplied _occName.
                if (!_occ.Name.ToUpper().Contains(_occName.ToUpper())) continue;

                // Validate the component is both visibile and active.
                if (_occ.Suppressed || !_occ.Visible) continue;

                PartComponentDefinition _definition = _occ.Definition as PartComponentDefinition;
                if (_definition == null) continue;

                ControlDefinition _def =
                       Application.CommandManager.ControlDefinitions["DrawingBodyHiddenLinesCtxCmd"];
                _def.Execute();
            }
        }
0 Likes