0 Replies Latest reply on Jul 30, 2015 6:20 AM by Prarthana Bataju

    Cannot generate D1Spacing in Linear Pattern

    Prarthana Bataju

      I am trying to generate some Linear pattern in my CAD data in SolidWorks using LocalLinearPatternFeatureData with some spacing using SolidWorks API for C #. When I try to generate number of patterns using only D1TotalInstances, it works. However when I try to apply some spacing within it ... using D1Spacing, it fails though it returns true The real problem is, is display given pattern number and spacing value when I check it directly into LocalPattern I already tried rebuilding it Here is my code:

      Private void ChangeLinearPatternLength ( ModelDoc2 SwModel , string StrCompPattern , double LengthMultipleVal , bool IsAdditionalNum = false )
        
      {
        
      ISelectionMgr SwSelMgr = SwModel . ISelectionManager ;

        SwModel
      . ClearSelection2 ( true );
        SwModel
      . Extension . SelectByID2 ( "NEC (B) _SA03-1 @ NEC_ASSY / SVKA (B) _SSA09-1 @ NEC (B) _SA03 " , "COMPONENT" , 0 , 0 , 0 , false , 0 , null , 0 );
        
      AssemblyDoc AssDoc = ( AssemblyDoc ) SwModel ;
        AssDoc
      . EditAssembly ();
        SwModel
      . ClearSelection2 ( true );

        SwModel
      . Extension . SelectByID2 ( "LocalLPattern1 @ NEC (B) _SA03-1 @ NEC_ASSY / NEC (B) _SSA09-1 @ NEC (B) _SA03" , "COMPPATTERN" , 0 , 0 , 0 , false , 0 , null , 0 );
        
      Feature SwFeature = SwSelMgr . GetSelectedObject6 ( 1 , - 1 );
        SwModel
      . ClearSelection2 ( true );

        
      string StrPatterName = SwFeature . GetTypeName2 . () ToUpper ();
        
      switch ( StrPatterName )
        
      {
        
      case "LOCALLPATTERN" :
        
      Debug . Print ( "Linear Pattern:" + SwFeature . Name );
        
      EruoshieilLinearPatternFeatureData LlpDefinition = default ( EruoshieilLinearPatternFeatureData );
        LlpDefinition
      = ( EruoshieilLinearPatternFeatureData ) SwFeature . getDefinition ();

        LlpDefinition
      . D1Spacing = ( double ) 300 / 1000 ;
        LlpDefinition
      . D1TotalInstances = 4 ;

        bool status
      = SwFeature . ModifyDefinition ( LlpDefinition , SwModel , null );
        SwModel
      . FeatEdit ();
        SwModel
      . ShowConfiguration2 ( "Default-_Flexible1" );
        
      Break ;
        
      }

        
      }

       

      Can anyone suggest me what am I missing or doing wrong here.